Class: Faalis::Dashboard::UsersController
- Inherits:
-
Dashboard::ApplicationController
- Object
- Dashboard::ApplicationController
- Faalis::Dashboard::UsersController
- Defined in:
- app/controllers/faalis/dashboard/users_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #edit_password ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #update_password ⇒ Object
Instance Method Details
#create ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/faalis/dashboard/users_controller.rb', line 26 def create Faalis::User #group_ids = user_params[:groups] parameters = user_params groups = parameters.delete(:groups) @user = Faalis::User.new(parameters) group_ids = groups.map(&:to_i) @user.groups = Faalis::Group.where(id: group_ids) respond_to do |f| if @user.save f.js f.html else f.js { render :errors } f.html end end end |
#destroy ⇒ Object
93 94 95 96 97 98 |
# File 'app/controllers/faalis/dashboard/users_controller.rb', line 93 def destroy @user = Faalis::User.find(params[:id]) @user @user.destroy end |
#edit ⇒ Object
20 21 22 23 24 |
# File 'app/controllers/faalis/dashboard/users_controller.rb', line 20 def edit @user = Faalis::User.find(params[:id]) @groups = Faalis::Group.all @user end |
#edit_password ⇒ Object
73 74 75 76 |
# File 'app/controllers/faalis/dashboard/users_controller.rb', line 73 def edit_password @user = Faalis::User.find(params[:id]) @user, :update? end |
#index ⇒ Object
4 5 6 7 |
# File 'app/controllers/faalis/dashboard/users_controller.rb', line 4 def index Faalis::User @users = Faalis::User.all end |
#new ⇒ Object
9 10 11 12 13 |
# File 'app/controllers/faalis/dashboard/users_controller.rb', line 9 def new Faalis::User @user = Faalis::User.new @groups = Faalis::Group.all end |
#show ⇒ Object
15 16 17 18 |
# File 'app/controllers/faalis/dashboard/users_controller.rb', line 15 def show @user = Faalis::User.find(params[:id]) @user end |
#update ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/faalis/dashboard/users_controller.rb', line 48 def update parameters = user_params groups = parameters.delete(:groups) @user = Faalis::User.find(params[:id]) @user unless groups.nil? group_ids = groups.map(&:to_i) @user.groups = Faalis::Group.where(id: group_ids) @user.save end respond_to do |f| if @user.update_without_password(parameters) f.js f.html else f.js { render :errors } f.html end end end |
#update_password ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/controllers/faalis/dashboard/users_controller.rb', line 78 def update_password @user = Faalis::User.find(params[:id]) @user, :update? respond_to do |f| if @user.update(password_params) f.js f.html else f.js { render :errors } f.html end end end |