Can someone please help me understand params in nested attributes a little better?
I am using Apotomo. But for the example. We could just assume its in the ApplicationController
I have a simple controller show action.
if params[:id].present?
@menu = Menu.find(params[:id])
else
@menu = Menu.first
end
Which checks to see if a menu id is specified in the URL. If not, it shows the first menu.
This works well as long as I'm only on the /menus/ URL.
But I have nested attributes. So once we visit URL /menus/17/categories/
It finds params[:id] as that of the category, not the menu.
Once I'm nested, I can call :menu_id, and it works fine. But no longer works on the parent object.
How do I look for params[:id] of the menu object regardless of where I am in the URL?
And am I missing something completely?
Here is my routs config as well:
resources :menus, :only => [:show, :home] do
resources :categories, :only => [:index, :show]
end
Thanks for your patience.