Class: Cmtool::UsersController

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

Instance Method Summary collapse

Methods included from ControllerGlue

#cmtool_user

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
# File 'app/controllers/cmtool/users_controller.rb', line 21

def create
  @user = ::User.new(user_params)
  if @user.save
    redirect_to cmtool.users_path, :notice => I18n.t('cmtool.action.create.successful', :model => ::User.model_name.human)
  else
    render :action => 'new'
  end
end

#destroyObject



44
45
46
47
48
# File 'app/controllers/cmtool/users_controller.rb', line 44

def destroy
  @user = ::User.find(params[:id])
  @user.destroy
  redirect_to cmtool.users_path, :notice => I18n.t('cmtool.action.destroy.successful', :model => ::User.model_name.human)
end

#editObject



13
14
15
# File 'app/controllers/cmtool/users_controller.rb', line 13

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

#indexObject

GET /cmtool/users



5
6
7
# File 'app/controllers/cmtool/users_controller.rb', line 5

def index
  @users = ::User.all
end

#newObject



17
18
19
# File 'app/controllers/cmtool/users_controller.rb', line 17

def new
  @user = ::User.new
end

#showObject



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

def show
  @user = ::User.find(params[:id])
end

#updateObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/cmtool/users_controller.rb', line 30

def update
  user = user_params
  unless user['password'].present?
    user.delete('password')
    user.delete('password_confirmation')
  end
  @user = ::User.find(params[:id])
  if @user.update_attributes(user)
    redirect_to cmtool.users_path, :notice => I18n.t('cmtool.action.update.successful', :model => ::User.model_name.human)
  else
    render :action => 'edit'
  end
end