Class: Strongbolt::UserGroupsUsersController

Inherits:
StrongboltController show all
Defined in:
app/controllers/strongbolt/user_groups_users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/strongbolt/user_groups_users_controller.rb', line 5

def create
  @user_group = UserGroup.find(params[:user_group_id])
  @user = Strongbolt.user_class_constant.find(params[:id])

  @user_group.users << @user unless @user_group.users.include?(@user)

  redirect_to request.referrer || user_group_path(@user_group)
rescue ActiveRecord::RecordNotUnique
  # user was already in the group, just ignoring this
  redirect_to request.referrer || user_group_path(@user_group)
end

#destroyObject



17
18
19
20
21
22
23
24
# File 'app/controllers/strongbolt/user_groups_users_controller.rb', line 17

def destroy
  @user_group = UserGroup.find(params[:user_group_id])
  @user = Strongbolt.user_class_constant.find(params[:id])

  @user_group.users.delete @user

  redirect_to request.referrer || user_group_path(@user_group)
end