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 and this change has only seemed to become
necessary as I've lately been using nested routes and nested form_for
stuff.
Can anyone confirm that using nested routes should not, in fact,
require wholesale changes like the one above to dependency
controllers?
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?
Perhaps if you were to answer the question I asked, I could help you
better.
Perhaps if you could say what you had already tried, and how it failed,
we could help you better.
But with the information you are providing, and your failure to answer
questions intended to gather additional information about the problem,
it is nearly impossible to help.
I feel like I need to understand how form_for must be adapted for use
with nested resources.