I have a Band
model and a BandMember
model. My routes definition is
resources :bands do
resources :band_members, as: :members, path: 'members'
end
Now I want to make a simple form for BandMember
like this:
<%= simple_form_for [@band, @band_member] do |f| %>
<% end %>
This throws an exception:
undefined method `band_band_member_path'
This would have worked if my model name was Member
instead of BandMember
. I do not wish to rename the model. Any ideas to get around this?
You can use the url
option of the simple_form_for
method:
<%= simple_form_for [@band, @band_member], url: your_url_helper_path do |f| %>
# ...
<% end %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.