simple roles

This commit is contained in:
Mark Moser 2015-10-19 22:05:48 -05:00
parent 0cefdaf15c
commit c204389103
3 changed files with 17 additions and 2 deletions

View File

@ -4,6 +4,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
before_filter :require_login before_filter :require_login
respond_to :html, :json respond_to :html, :json
helper :access
private private

View File

@ -0,0 +1,13 @@
module AccessHelper
def can_create_user? user
user && user.admin?
end
def can_edit_user? user
user && user.admin?
end
def can_page? user
user && (user.admin? || user.staff?)
end
end

View File

@ -3,5 +3,6 @@
%li{ class: active_controller('parents') }= link_to 'Parents', list_parents_path %li{ class: active_controller('parents') }= link_to 'Parents', list_parents_path
%li{ class: active_controller('children') }= link_to 'Children', list_children_path %li{ class: active_controller('children') }= link_to 'Children', list_children_path
%li{ class: active_controller('pages') }= link_to 'Pages', list_pages_path %li{ class: active_controller('pages') }= link_to 'Pages', list_pages_path
- if can_edit_user? current_user
%li{ class: active_controller('staff') }= link_to 'Staff', list_staff_path %li{ class: active_controller('staff') }= link_to 'Staff', list_staff_path
%li{ class: active_controller('users') }= link_to 'Users', list_users_path %li{ class: active_controller('users') }= link_to 'Users', list_users_path