Ruby on Rails layouts...except and only bug
layout, ruby-on-rails
Solution
Another option is to define a method for your layout call, like so:
layout :compute_layout
and then
def compute_layout
action_name == "privacy" ? "static" : "sessions"
end
However this is really only useful when you want to determine the layout at runtime based on some runtime parameter (like a variable being set). In your example, that does not seem to be necessary.
Problem
I have a controller with the following layout logic ``` layout 'sessions', :except => :privacy layout 'static', :only => :privacy ``` The issue is that Rails seems to ignore the first line of code and the layout "sessions" is not applied for any actions. It simply thinks to render the static layout for privacy and no layout for the rest. Anyone know how to fix this?