Class: API::V1::GroupsController
- Inherits:
-
APIController
- Object
- APIController
- API::V1::GroupsController
- Defined in:
- app/controllers/red_base/api/v1/groups_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
-
#index ⇒ Object
GET /api/v1/groups.
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/red_base/api/v1/groups_controller.rb', line 15 def create :create, RedBase::Group = []; (params[:permissions] || []).each do |perm_string| perm, model = perm_string.split "|" = Permission.(model, perm) << end @group = Group.create!({ name: params[:name], permissions: , }) respond_with(@group) end |
#destroy ⇒ Object
57 58 59 60 61 62 |
# File 'app/controllers/red_base/api/v1/groups_controller.rb', line 57 def destroy ids = params[:id].split(",") @groups = Group.where(:id => ids) :destory, @groups @groups.destroy_all end |
#index ⇒ Object
GET /api/v1/groups
9 10 11 12 13 |
# File 'app/controllers/red_base/api/v1/groups_controller.rb', line 9 def index @groups = Group.includes(:permissions).all :read, @groups respond_with(@groups) end |
#show ⇒ Object
34 35 36 37 38 |
# File 'app/controllers/red_base/api/v1/groups_controller.rb', line 34 def show @group = Group.find(params[:id]) :read, @group respond_with(@group) end |
#update ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/red_base/api/v1/groups_controller.rb', line 40 def update @group = Group.find(params[:id]) :update, @group = []; (params[:permissions] || []).each do |perm_string| perm, model = perm_string.split "|" = Permission.(model, perm) << end @group.update(:name => params[:name], :permissions => ) respond_with(@group) end |