i’m using rails 4.2.7. want define filter subject conditions. have
class applicationcontroller < actioncontroller::base before_filter :store_last_page_visited unless logged_in? … private def current_user @current_user ||= user.find_by(id: session[:user_id]) end def logged_in? !current_user.nil? end def store_last_page_visited session[:last_page_visited] = request.url end helper_method :current_user, :logged_in?
however, when visit page in application, error
undefined method `logged_in?' applicationcontroller:class did mean? logger
what need differently filter executed when specify?
before_filter
executed in context of class.
#logged_in?
defined in context of class instance.
try this:
def store_last_page_visited return if logged_in? session[:last_page_visited] = request.url end
Comments
Post a Comment