I apologize if this the incorrect mailing list, as it is a Rails question,
not really a Ruby question. Anyway:
To apply a layout to a controller, you can say:
class UsersController < ApplicationController
layout "master"
end
...which you would need to do in every controller. So my first thought is to
push this down into ApplicationController, mitigating the need to put
anything layout related in all the other controllers:
class ApplicationController < ActionController::Base
layout "master"
end
...which doesn't work. So my next thought is to declare an instance variable
in the ApplicationController:
class ApplicationController < ActionController::Base
@layout = "master"
end
and change all other controllers to look like this:
class UsersController < ApplicationController
layout @layout
end
...which doesn't work either. So I grudgingly try a global with the same
thought process:
class ApplicationController < ActionController::Base
$layout = "master"
end
class UsersController < ApplicationController
layout $layout
end
...which works. But I don't understand why, if UsersController derives from
ApplicationController, the other two methodologies fail. Can someone explain
this to me?
Centralizing the layout moniker to one place will help significantly as I
move my app from test/dev/prod, so I can have alarmingly different layouts
for test/dev versus production.
···
--
Brock Weaver
http://www.circaware.com