mjc
mjc

Reputation: 3426

form_for Nested Resources

Here is the route:

 map.resources :networks do |network|
    network.resources :channels, :name_prefix => nil
  end

Here is what I have in my for my form.

<% form_for ([@network, @channel]) do |f| %>
...
<% end %>

I get an undefined method error since form_for is trying to call "network_channel_path". This error occurs because I have the channels :name_prefix as nil. How can I avoid this problem without completely writing out form_form with all the needed parameters?

Upvotes: 0

Views: 1317

Answers (1)

ErsatzRyan
ErsatzRyan

Reputation: 3043

instead of using :name_prefix => nil use :shallow => true

This will not display the networks/:network_id and not mess with your _paths

Upvotes: 1

Related Questions