I just run into a problem similar to http://www.ruby-forum.com/topic/216433
I need to access the controller instance variable from the helper.
Here is the code I made and it does not work.
Controller:
class ApplicationController < ActionController::Base helper_method :set_background_type #for action only background setting #for controller-wise background setting def set_background_type(string) @background_type = string end end
Helper:
module ApplicationHelper def background_type @background_type || 'default' end end
Markup:
<body class="<%= background_type %>">
ruby-on-rails-3
Stackng
source share