Guide to creating an admin panel in a rails app
... refers to the global module namspace folder, ex. summitrails g migration add_admin_to... admin:boolean
Users.first.update_column :admin, true
admin_controller.rb/admin and should be defaulted to the index actionnamespace :admin do
get '/' => 'admin#index'
end
user.admin == true, if current_user.admin?, then provide the link_to the admin pageapp/views/.../admin/admin/index.html.erbrails g cancan:ability
def current_ability
@current_ability ||= Samurai::Ability.new(current_user)
end
rescue_from CanCan::AccessDenied do |exception|
render :file => 'static/403.html", :status => 403, :layout => false
end
authorize_resource class: false
if user.admin?
can :manage, :all
else
can :read, :dashboard
end