Agoofin: The only reason I am doing it this way is for the current_user. This is the only way I know how to make sure another user does not see a record created by someone else. If I knew another way to do this then I would avoid the nested resources. I can see where my current model is going to become a pain to manage. If I knew how to do that I would change my ways. Currently I do:
current_user.children.find(child).dogs.build(params[:dog]) I know there has to be a better way but I am glad it's working now. I am new and am sure as I improve I will discover the appropriate way to handle this. Thanks for the feedback. On Sep 20, 5:32 pm, AGoofin <[email protected]> wrote: > One other way to think about this - you shouldn't need to nest > resources more then one level deep. > > You only deal with children in relation to parents and dogs in > relation to children. Separate relationships which can be handled > transparently. Plus the links you have to generate get a lot more > confusing - parents_childrens_dog_path( parent_id, child_id, dog_id) > or some such... > > On Sep 20, 1:41 pm, mlittle <[email protected]> wrote: > > > MichaelB: > > > THANK YOU!!!!! So much. Your solution fixed my problem and taught me a > > bunch about rails. > > > Thanks again for your help. > > > On Sep 20, 8:32 am, MichaelB <[email protected]> wrote: > > > > Hey mlttle- > > > > You can create a new dog with: > > > > def create > > > @dog = Parent.find(params[:parent_id]).children.find(params > > > [:child_id]).dogs.create > > > end > > > > The console is your best friend to quickly diagnose errors: > > > > >> @record= parent.child.dog.build(params[:dog]) > > > > NoMethodError: undefined method `child' for #<Parent:0x22b6748> > > > > .. becuase your parent model has many **children** > > > > >> @record= parent.children.find(child).dogs.build(params[:dog]) > > > > Michael --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

