Skip to content

Instantly share code, notes, and snippets.

@sevenseacat
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save sevenseacat/b68170f9c66c21365df4 to your computer and use it in GitHub Desktop.

Select an option

Save sevenseacat/b68170f9c66c21365df4 to your computer and use it in GitHub Desktop.
class PostsController < ApplicationController
before_filter :authenticate_user, except: [:index, :show]
def authenticate_user
# I presume you have a current_user helper defined on your controller to get the authenticated user?
raise ActionController::RoutingError, 'No valid user' unless current_user.present?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment