You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TYETECHNOLOGIES edited this page Sep 20, 2017
·
1 revision
Security
In a production application you'll likely want to protect access to this information. You can use the constraints feature of routing to accomplish this:
Devise
Checks a User model instance that responds to admin?
Checks a User model instance that responds to admin?
# lib/admin_constraint.rb
class AdminConstraint
def matches?(request)
return false unless request.session[:user_id]
user = User.find request.session[:user_id]
user && user.admin?
end
end
# config/routes.rb
require "admin_constraint"
match 'rubyception' => 'rubyception/application#index, :constraints => AdminConstraint.new