Skip to content

Instantly share code, notes, and snippets.

@sapslaj
Created June 21, 2015 17:11
Show Gist options
  • Select an option

  • Save sapslaj/8826ebe6f50055bf751a to your computer and use it in GitHub Desktop.

Select an option

Save sapslaj/8826ebe6f50055bf751a to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
@public_actions = [:new, :create, :validate, :show, :index]
before_filter :require_login, except: @public_actions
def not_authenticated
redirect_to login_path, notice: "You must log in first to access this"
end
protected
def render_error(error_code=403, layout=false)
render(:file => File.join(Rails.root, "public/#{error_code}.html"), :status => error_code, :layout => layout)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment