Class: UserGroupsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/user_groups_controller.rb

Instance Method Summary (collapse)

Methods inherited from ApplicationController

#is_current_user?

Instance Method Details

- (Object) create



13
14
15
16
17
18
19
20
21
# File 'app/controllers/user_groups_controller.rb', line 13

def create
  @user_group = @user.user_groups.create(params[:user_group])
  if @user_group.valid?
    @user.save
    redirect_to user_user_groups_path(@user), notice: t(:user_group_successfully_created)
  else
    render :new
  end
end

- (Object) destroy



38
39
40
41
42
43
# File 'app/controllers/user_groups_controller.rb', line 38

def destroy
  @user_group = @user.user_groups.find(params[:id])
  @user_group.delete
  @user.save
  redirect_to  user_user_groups_path(@user), notice: t(:user_group_successfully_deleted)
end

- (Object) edit



23
24
25
# File 'app/controllers/user_groups_controller.rb', line 23

def edit
  @user_group = @user.user_groups.find(params[:id])
end

- (Object) index



6
7
# File 'app/controllers/user_groups_controller.rb', line 6

def index
end

- (Object) new



9
10
11
# File 'app/controllers/user_groups_controller.rb', line 9

def new
  @user_group = @user.user_groups.build
end

- (Object) update



27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/user_groups_controller.rb', line 27

def update
  @user_group = @user.user_groups.find(params[:id])
  @user_group.update_attributes(params[:user_group])
  if @user_group.valid?
    @user.save
    redirect_to user_user_groups_path(@user), notice: t(:user_group_successfully_updated)
  else
    render :new
  end
end