I am trying to route a submit button to a specific path (page), but I believe my syntax is not accurate.
This is what I have now:
<%= submit_tag('Next (Step 2 of 3)'), customer_index_path %>
I am getting the error:
/Users/anmareewilliams/RailsApps/GroupOrderingCopy/app/views/products/index.html.erb:18: syntax error, unexpected ',', expecting ')'
...bmit_tag('Next (Step 2 of 3)'), customer_index_path );@outpu...
...
I tried this as well:
<%= submit_tag'Next (Step 2 of 3)', customer_index_path %>
and got no errors in the text editor, but got a Rails error that said:
undefined method `stringify_keys' for "/customer/index":String
How can I accomplish routing my submit to a specific path?
You don't include path
in submit_tag
. You need to define the path in your form
's action
.
<%= form_tag(customer_index_path) do %>
<%= submit_tag 'Next (Step 2 of 3)' %>
<% end %>
This should submit the form to customer_index_path
.
Update:
To submit a GET
request to #customer_index_path
, you need to update the form_tag
declaration as follows:
<%= form_tag(customer_index_path, method: :get) do %>
<%= submit_tag 'Next (Step 2 of 3)' %>
<% end %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With