Hello,
I have the view:
<% form_tag ‘/’ do %>
<%= number_field_tag(:number_one) %>
<%= number_field_tag(:number_two) %>
<%= submit_tag ‘Calculate’ %>
<% end %>
<%= @number %>
and the controller:
def add
numberone = params[:number_one].to_f
numbertwo = params[:number_two].to_f
@number = numberone + numbertwo
end
I am trying to learn some ujs in rails with this example, but I can’t
get it to work. I would like it to not refresh the page to load @number
unobtrusively. Every time I try the submit_tag just stops working. I
have read many tutorials and such teaching how to get form_for forms to
use javascript, but not an example as simple as mine. Should I create a
.js file named add.js? ect. ect.
Point me in the right direction?
Thanks