I am currently working on re factoring my controllers and views to
better follow the DRY principal. I have done significant work with the
controllers but am struggling with the views...
I have the standard type layout, a header (includes a navigation bar),
then the content, followed by a footer.
In the content section there is a title, basically the action name,
and available actions followed by some dynamic content. The actions
contain a create, list, and search button and other action specific
actions. Right now those actions are defined in each page. I am trying
to factor that out and create an action partial which will be shared
amongst most of my controllers. How can I define a "default" list of
actions and then when needed override those defaults?
so for my views i need to declare the actions, most likely should be
in a partial... the standard list
<% content_for :actions %>
<%= link_to "New", :action => "new" %>
<%= link_to "List", :action => "list" %>
<%= link_to "Search", :action => "search" %>
<% end %>
then i could have a set of other actions that aren't ordinary. So i
guess then in about 95% of my views i will have:
<%= render :partial => "default_actions" %>
and sometimes additional renders for other action sets I may need. Now
my problem is that because I don't always want to display the action
menu, I cannot add the above render to my layout because then it would
show all the time. So I would have to put the render in every one of
my views when I want it. But seeing how it is needed more often than
not, should I put the render call in my layout and a conditional
statement to hide it when desired, I certainly do not want to clutter
my views with conditional code when not needed. What would be the best
way to handle this situation?