ref: master
app/controllers/admin/role_controller.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
class RoleController < AdminController protect 'manage_environment_roles', :environment def index @roles = environment.roles.where profile_id: nil end def new @role = Role.new end def create @role = Role.new :name => params[:role][:name], :permissions => params[:role][:permissions], :environment => environment if @role.save redirect_to :action => 'show', :id => @role else session[:notice] = _('Failed to create role') render :action => 'new' end end def show @role = environment.roles.find(params[:id]) end def edit @role = environment.roles.find(params[:id]) end def update @role = environment.roles.find(params[:id]) if @role.update(params[:role]) redirect_to :action => 'show', :id => @role else session[:notice] = _('Failed to edit role') render :action => 'edit' end end end |