In my application-controller.rb I did:
def show_footer?
开发者_开发知识库 @show_footer = true
end
Then in my view I am getting an error saying show_footer? isn't defined.
note, this view is in another controller then inherits application_controller.
Controller methods are not in scope to views; only helper methods are. You can add a controller method as a helper also by doing the following:
class ApplicationController < ActionController::Base
helper_method :show_footer?
def show_footer?
# Your method implementation.
end
end
Now you'll be able to refer to show_footer?
in both your controllers and your views.
Put it in application_helper.rb
instead.
Also, you probably mean to have @show_footer == true
instead of =
.
精彩评论