Rails layout: 2 cols cache and content_for

Hy,

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

Answers


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


Need Your Help

Minimal standalone install of Microsoft Device Emulator

windows-mobile windows-mobile-6.5 device-emulator-manager

I have installed the Microsoft Device Emulator 3.0 and the Windows Mobile 6.5 DTK on a clean Windows 7 system. From the Start menu, I can start an emulator.

Backpropagation for rectified linear unit activation with cross entropy error

matlab machine-learning neural-network backpropagation

I'm trying to implement gradient calculation for neural networks using backpropagation.