Rails layout: 2 cols cache and content_for
I have a layout that has 2 cols and in every view i have: content_for :main_col and content_for :side_col
in some parts of the site, the side_col is always the same and how do i do that being DRY? partial render? i dont think is so good.
then it comes to cache.. the content_for is not good to cache...
you have better ideias on how to implement this?thanks
your question is a bit vague, but from what i'm understanding, if you don't want to make a partial, then you could just put markup for side_col directly in the application layout instead of having the named yield. then make sure that any variables you need in that view are set in the ApplicationController. if there are views that don't require the side_col, then you can set an instance variable, say, @include_side_col = true in your application controller, then wrap the side_col in an if statement checking that variable. in your sub controllers, you could then set @include_side_col to false in a before_filter. That is one way to do it, but I must say that I would prefer the partial method as it is more of a rails convention, and it keeps you from cluttering your application layout