chewmanfoo wrote:
> I have a lot of has_many and has_many :through relationships in an
> application with approx 100 models.  I would like to move to nested
> routes, but I just wanted to be sure I understood the scope of the
> project.  Essentially, I see this as two tasks:
> 
> 1.) modify config/routes.rb such that my relationships are expressed
> in nested route statements
> 2.) modify every route reference in a link_to etc to use the new
> nested route name (instead of new_ip_address, I'd have
> new_network_ip_address etc.)
> 
> Is that about it?

typically you would also have to slightly modify your controllers:
instead of
  @ip_address = IpAddress.new
you should use
  @network = Network.find(params[:network_id])
  @ip_address = @network.ip_adresses.build

and instead of
  @ip_address = IpAddress.find(params[:id])
use
  @network = Network.find(params[:network_id])
  @ip_address = @network.ip_adresses.find(params[:id])

this isn't really necessary, but this way rails will take care of the 
association (e.g. automatically assign :network_id when you call build)
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to