Class: Cmtool::UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Cmtool::UsersController
- Defined in:
- app/controllers/cmtool/users_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
-
#index ⇒ Object
GET /cmtool/users.
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/controllers/cmtool/users_controller.rb', line 21 def create @user = ::User.new(params[:user]) 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 |
#destroy ⇒ Object
48 49 50 51 52 |
# File 'app/controllers/cmtool/users_controller.rb', line 48 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 |
#edit ⇒ Object
13 14 15 |
# File 'app/controllers/cmtool/users_controller.rb', line 13 def edit @user = ::User.find(params[:id]) end |
#index ⇒ Object
GET /cmtool/users
5 6 7 |
# File 'app/controllers/cmtool/users_controller.rb', line 5 def index @users = ::User.all end |
#new ⇒ Object
17 18 19 |
# File 'app/controllers/cmtool/users_controller.rb', line 17 def new @user = ::User.new end |
#show ⇒ Object
9 10 11 |
# File 'app/controllers/cmtool/users_controller.rb', line 9 def show @user = ::User.find(params[:id]) end |
#update ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/cmtool/users_controller.rb', line 30 def update user = params[:user] unless user['password'].present? user.delete('password') user.delete('password_confirmation') end @user = ::User.find(params[:id]) if @user.update_attributes(user) if user['password'] # Sign in after changing current logged in password sign_in(@user, :bypass => true) if @user == current_user end redirect_to cmtool.users_path, :notice => I18n.t('cmtool.action.update.successful', :model => ::User.model_name.human) else render :action => 'edit' end end |