Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix 'Calculator' page reverting after changing locale #928

Merged
merged 15 commits into from
Dec 9, 2024
Prev Previous commit
Next Next commit
fix redirection and check tests
NVMakarenko committed Nov 9, 2024
commit d4e96f592972d1e6418d907367e75562d5526373
1 change: 1 addition & 0 deletions app/controllers/account/calculators_controller.rb
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ def create

respond_to do |format|
if @calculator.save
flash[:notice] = t("notifications.calculator_created")
format.html { redirect_to account_calculators_path, notice: t("notifications.calculator_created") }
format.turbo_stream
else
4 changes: 2 additions & 2 deletions app/views/account/calculators/create.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= turbo_stream.append "body" do %>
<%= turbo_stream.append "redirect" do %>
<script>
window.location.replace("<%= account_calculators_path %>");
window.location.assign("<%= account_calculators_path %>");
</script>
<% end %>
1 change: 1 addition & 0 deletions app/views/account/calculators/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%= turbo_frame_tag "redirect" %>
<div class="container">
<%= render "account/calculators/partials/new/form", calculator: @calculator %>
</div>
22 changes: 11 additions & 11 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -3,18 +3,18 @@
# Be sure to restart your server when you modify this file.

Rails.application.config.content_security_policy do |policy|
# policy.default_src :self, :https
# policy.font_src :self, :https, :data
# policy.img_src :self, :https, :data
# policy.object_src :none
policy.script_src :self, :https, :unsafe_inline, :blob
# policy.style_src :self, :https
# # If you are using webpack-dev-server then specify webpack-dev-server host
# policy.connect_src :self, :https, "http://localhost:3035",
# "ws://localhost:3035" if Rails.env.development?
# policy.default_src :self, :https
# policy.font_src :self, :https, :data
# policy.img_src :self, :https, :data
# policy.object_src :none
policy.script_src :self, :https, :unsafe_inline, :blob
# policy.style_src :self, :https
# # If you are using webpack-dev-server then specify webpack-dev-server host
# policy.connect_src :self, :https, "http://localhost:3035",
# "ws://localhost:3035" if Rails.env.development?

# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
# # Specify URI for violation reports
# # policy.report_uri "/csp-violation-report-endpoint"
end

# If you are using UJS then enable automatic nonce generation