Class: RbacRls::GroupsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RbacRls::GroupsController
- Includes:
- ConnectionRlsUserConcern
- Defined in:
- app/controllers/rbac_rls/groups_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /groups.
-
#destroy ⇒ Object
DELETE /groups/1.
-
#edit ⇒ Object
GET /groups/1/edit.
- #get_options_select ⇒ Object
-
#index ⇒ Object
GET /groups.
-
#new ⇒ Object
GET /groups/new.
-
#show ⇒ Object
GET /groups/1.
-
#update ⇒ Object
PATCH/PUT /groups/1.
Instance Method Details
#create ⇒ Object
POST /groups
26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/rbac_rls/groups_controller.rb', line 26 def create @group = Group.new(group_params) if @group.save redirect_to @group, notice: "Group was successfully created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
DELETE /groups/1
46 47 48 49 |
# File 'app/controllers/rbac_rls/groups_controller.rb', line 46 def destroy @group.destroy redirect_to groups_url, notice: "Group was successfully destroyed." end |
#edit ⇒ Object
GET /groups/1/edit
22 23 |
# File 'app/controllers/rbac_rls/groups_controller.rb', line 22 def edit end |
#get_options_select ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/rbac_rls/groups_controller.rb', line 51 def @permission = Permission.find_by(id: params[:permission_object_id]) if @permission.present? attrs = @permission.table_name.singularize.camelize.constantize.new.attributes.keys if params[:target_select].to_s.to_sym == :table_key_id @collection = [attrs, attrs].transpose.to_h if params[:target_select].to_s.to_sym == :table_key_id elsif params[:target_select].to_s.to_sym == :table_value_id elements = @permission.table_name.singularize.camelize.constantize.all.map(¶ms[:permission_id].to_s.to_sym) @collection = [elements, elements].transpose.to_h end end render json: @collection.to_h.as_json end |
#index ⇒ Object
GET /groups
7 8 9 |
# File 'app/controllers/rbac_rls/groups_controller.rb', line 7 def index @groups = Group.all end |
#new ⇒ Object
GET /groups/new
16 17 18 19 |
# File 'app/controllers/rbac_rls/groups_controller.rb', line 16 def new @group = Group.new @group..build() end |
#show ⇒ Object
GET /groups/1
12 13 |
# File 'app/controllers/rbac_rls/groups_controller.rb', line 12 def show end |
#update ⇒ Object
PATCH/PUT /groups/1
37 38 39 40 41 42 43 |
# File 'app/controllers/rbac_rls/groups_controller.rb', line 37 def update if @group.update(group_params) redirect_to @group, notice: "Group was successfully updated." else render :edit, status: :unprocessable_entity end end |