I'm using SimpleForm in Rails 3. How do I make the submit button for this nested resource?
resources :schools do
resources :students
end
<%= simple_form_for @student do |f| %>
<%= f.input :first_name %>
<%= f.input :last_name %>
<%= f.button :submit %>
<% end %>
If I use f.submit
:
ActionView::Template::Error (undefined method `students_path' for #<#<Class:0x000001040ddfb8>:0x000001040d2578>):
1: <%= simple_form_for @student do |f| %>
2: <%= f.input :first_name %>
3: <%= f.input :last_name %>
4: <%= f.submit %>
The right code for the view is:
<%= simple_form_for [@school, @student] do |f| %>
<%= f.input :first_name %>
<%= f.input :last_name %>
<%= f.button :submit %>
<% 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