Class: UserGroupsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /user_groups POST /user_groups.json



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/user_groups_controller.rb', line 42

def create
  @user_group = UserGroup.new(user_group_params)

  respond_to do |format|
    if @user_group.save
      format.html { redirect_to @user_group, notice: t('controller.successfully_created', model: t('activerecord.models.user_group')) }
      format.json { render json: @user_group, status: :created, location: @user_group }
    else
      prepare_options
      format.html { render action: "new" }
      format.json { render json: @user_group.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /user_groups/1 DELETE /user_groups/1.json



79
80
81
82
83
84
85
86
# File 'app/controllers/user_groups_controller.rb', line 79

def destroy
  @user_group.destroy

  respond_to do |format|
    format.html { redirect_to user_groups_url }
    format.json { head :no_content }
  end
end

#editObject

GET /user_groups/1/edit



37
38
# File 'app/controllers/user_groups_controller.rb', line 37

def edit
end

#indexObject

GET /user_groups GET /user_groups.json



8
9
10
11
12
13
14
15
# File 'app/controllers/user_groups_controller.rb', line 8

def index
  @user_groups = UserGroup.order(:position)

  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @user_groups }
  end
end

#newObject

GET /user_groups/new



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

def new
  @user_group = UserGroup.new

  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @user_group }
  end
end

#showObject

GET /user_groups/1 GET /user_groups/1.json



19
20
21
22
23
24
# File 'app/controllers/user_groups_controller.rb', line 19

def show
  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @user_group }
  end
end

#updateObject

PUT /user_groups/1 PUT /user_groups/1.json



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/controllers/user_groups_controller.rb', line 59

def update
  if params[:move]
    move_position(@user_group, params[:move])
    return
  end

  respond_to do |format|
    if @user_group.update(user_group_params)
      format.html { redirect_to @user_group, notice: t('controller.successfully_updated', model: t('activerecord.models.user_group')) }
      format.json { head :no_content }
    else
      prepare_options
      format.html { render action: "edit" }
      format.json { render json: @user_group.errors, status: :unprocessable_entity }
    end
  end
end