Class: Admin::GroupsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ApplicationController
- Admin::GroupsController
- Defined in:
- app/controllers/admin/groups_controller.rb
Overview
Instance Method Summary collapse
-
#create ⇒ Object
POST /admin/groups.
-
#destroy ⇒ Object
DELETE /admin/groups/1.
-
#edit ⇒ Object
GET /admin/groups/1/edit.
-
#index ⇒ Object
GET /admin/groups.
-
#new ⇒ Object
GET /admin/groups/new.
-
#update ⇒ Object
PATCH/PUT /admin/groups/1.
Methods inherited from ApplicationController
#default_url_options, #new_session_path
Instance Method Details
#create ⇒ Object
POST /admin/groups
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/admin/groups_controller.rb', line 27 def create @group = Group.new(group_params) set_users if @group.save @status = { success: "Gruppo creato" } redirect_to admin_groups_path else @status = { error: "Creazione gruppo fallita" } render action: "edit" end end |
#destroy ⇒ Object
DELETE /admin/groups/1
53 54 55 56 |
# File 'app/controllers/admin/groups_controller.rb', line 53 def destroy @group.destroy redirect_to admin_groups_path, notice: "Group was successfully destroyed." end |
#edit ⇒ Object
GET /admin/groups/1/edit
22 23 24 |
# File 'app/controllers/admin/groups_controller.rb', line 22 def edit @users = User.editors.pluck :email, :id end |
#index ⇒ Object
GET /admin/groups
10 11 12 13 |
# File 'app/controllers/admin/groups_controller.rb', line 10 def index @text = [ "title ilike :text", { text: "%#{filter_params[:text]}%" } ] if filter_params[:text].present? @pagy, @groups = pagy(Group.all.where(@text)) end |
#new ⇒ Object
GET /admin/groups/new
16 17 18 19 |
# File 'app/controllers/admin/groups_controller.rb', line 16 def new @group = Group.new render action: "edit" end |
#update ⇒ Object
PATCH/PUT /admin/groups/1
41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/admin/groups_controller.rb', line 41 def update @users = @group.users.pluck :email, :id if @group.update(group_params) @status = { success: "Gruppo aggiornato" } redirect_to admin_groups_path else @status = { error: "Aggiornamento gruppo fallito" } render :edit end end |