Marnen,

Here is the expression of a representative model association in my
project:

Parent ... has_one :dependent
Dependent ... belongs_to :parent

Here is my complementing route:

map.resources :parents, :has_one => [:dependent, :dependent_2, ...

Here is a change I'd lately made to a _form.html.erb partial in views/
children to make things (kind of) work:

<% form_for([:parent, @child], :url => { :action=>:create }) do |f| %>

Man, I'm vexed!

I feel like I need to understand how form_for must be adapted for use
with nested resources.

Grar


On Apr 26, 10:35 am, Marnen Laibow-Koser <li...@ruby-forum.com> wrote:
> Grary Stimon wrote:
> > Hi,
>
> > I'm new to nested resources. I'm surprised to find that to make my
> > code work I need to retrieve the parent model in my RESTful
> > controllers for my dependencies.
>
> > So, for example, let's say A has_one B. In controller B I seem to need
> > to refer to parent A, for example:
>
> > @b = A.find(params[:a_id]).b
>
> > But this doesn't seem right
>
> No, it doesn't.  You should always be able to do B.find(params[:b_id]) .
> What happens when you try?
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...@marnen.org
> --
> Posted viahttp://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 rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to