I have a bunch of admin controllers in my Merb app that I want to use a different layout from my other controllers. My admin controllers should use the 'admin' layout, and the rest of my controllers should use the 'application' layout.
I can make them use the 'admin' layout by doing this:
class Admin::Users < Application
self._layout = 'admin'
end
And that works, but I think this would be better:
class Admin::Users < Application
layout :admin
end
For now, I've made it work like that by defining the layout method in my Application controller (from which all my other controllers inherit):
class Application < Merb::Controller
def self.layout(name)
self._layout = name.to_s
end
end
Thanks to Yann KLIS on the merb-devel mailing list for showing me how to use self._layout = 'foo'.