You can pass the before_filter block:
before_filter { |c| !c.logged_in? }
But this would not do anything, since the return value from the before filter will not go anywhere. If you want to perform an action if the user is not logged in, you must put this action in the before_filter file.
For example, if the action was redirected to the login page, path, you can do this:
before_filter { |c| redirect_to login_path unless c.logged_in? }
This is long enough to justify its own method:
before_filter :login_required def login_required redirect_to login_path unless logged_in? end
source share