Everything is ok when I call it from my primary controller, but since I
am also calling the layout from a second controller that does not have
list defined I am getting an error.
What I’d like to do is make the action => “list” absolute so that it
goes to action => controller “primary” =>“list”
Is there any way to do that? Or else do I just have to define list a
second time in the second controller?
There are a few ways to make shared components like this work. One
was already mentioned in that you could just specify a certain
controller on the link_to. You could also define sidebar as a shared
component which would live at app>views>shared and include it where
you’d like via <%= render(:partial => “shared/sidebar”) %>.
Additionally, you could make it a component in the components
directory (same level as app). A good start info-wise is here: Peak Obsession. You’ll still
need to specify what controller / action you want in each of the
sidebar links, but this follows the DRY principal quite nicely by
locating the sidebar in one location.
Everything is ok when I call it from my primary controller, but since I
am also calling the layout from a second controller that does not have
list defined I am getting an error.
What I’d like to do is make the action => “list” absolute so that it
goes to action => controller “primary” =>“list”
Is there any way to do that? Or else do I just have to define list a
second time in the second controller?
Perhaps just make it conditional in your layout (change the name to the
one
where you don’t want it visible, assuming it should be visible in all
others):
I’ve found in some circumstances say a User controller, and an
Admin::User
controller,
that rails can get confused. since the User and Admin::User are really
both
User Controllers. That’s why I’ve added the extra / in the action.