Skip to content

Instantly share code, notes, and snippets.

@maulayyacyber
Created June 11, 2018 04:32
Show Gist options
  • Save maulayyacyber/82e9b5f94bc378d143ea44b4525d21e3 to your computer and use it in GitHub Desktop.
Save maulayyacyber/82e9b5f94bc378d143ea44b4525d21e3 to your computer and use it in GitHub Desktop.
def not_found
raise ActionController::RoutingError.new('Not Found')
rescue
render_404
end
def render_404
render file: "#{Rails.root}/app/views/errors/error404", status: :not_found
end
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
helper_method :current_user
def authorize
not_found unless current_user
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment