I have a calculator which users would enter in values, hit submit and without refreshing or re-rendering, the calculated values would display on the page. All worked well until I upgraded from Rails 6.1.4.6 to 7.0.2.2. Now I receive this error below:
When I add format.html to the respond_to block, I get this error:
When I add format.html { render :new } to the respond_to block, the page re-renders the new.html.erb file but without calculated values (i.e create.js.erb file is not running).
Any help would be appreciated.
Here are the files that ran perfectly in Rails 6.
calculator_controller.rb
def create
@calculation = calculate_one_option
respond_to do |format|
format.js
end
end
def new; end
new.html.erb
<%= form_tag calculate_path, method: :post, remote: true do %>
... form stuff ...
<%= submit_tag "Calculate" %>
<% end %>
create.js.erb
var formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' });
if ("<%= @calculation.error %>".length > 0 ) {
alert("<%= @calculation.error %>");
... js stuff ...
} else {
... more js stuff ...
}

