Class: Droom::UsersController
- Inherits:
-
EngineController
- Object
- ApplicationController
- EngineController
- Droom::UsersController
- Defined in:
- app/controllers/droom/users_controller.rb
Instance Method Summary collapse
- #admin ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
-
#update ⇒ Object
This has to handle small preference updates over js and large account-management forms over html.
Methods inherited from EngineController
Instance Method Details
#admin ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/droom/users_controller.rb', line 19 def admin @users = @users.in_name_order if params[:q].blank? @users = @users.in_any_directory_group else @users = @users.matching(params[:q]) end @users = paginated(@users, 100) respond_with @users end |
#create ⇒ Object
45 46 47 48 |
# File 'app/controllers/droom/users_controller.rb', line 45 def create @user.update_attributes(user_params) respond_with @user end |
#destroy ⇒ Object
74 75 76 77 |
# File 'app/controllers/droom/users_controller.rb', line 74 def destroy @user.destroy head :ok end |
#edit ⇒ Object
50 51 52 |
# File 'app/controllers/droom/users_controller.rb', line 50 def edit respond_with @user end |
#index ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/droom/users_controller.rb', line 9 def index @users = @users.in_name_order @users = @users.matching(params[:q]) unless params[:q].blank? @users = paginated(@users, 50) respond_with @users do |format| format.js { render :partial => 'droom/users/users' } format.vcf { render :vcf => @users.map(&:to_vcf) } end end |
#new ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/droom/users_controller.rb', line 35 def new if params[:group_id].present? @user.groups << Droom::Group.find(params[:group_id]) end if params[:organisation_id].present? && Droom.use_organisations? @user.organisation = Droom::Organisation.find(params[:organisation_id]) end respond_with @user end |
#show ⇒ Object
30 31 32 33 |
# File 'app/controllers/droom/users_controller.rb', line 30 def show @invitation = Droom::Invitation.find(params[:invitation_id]) if params[:invitation_id].present? respond_with @user end |
#update ⇒ Object
This has to handle small preference updates over js and large account-management forms over html.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/droom/users_controller.rb', line 56 def update if @user.update_attributes(user_params) sign_in(@user, :bypass => true) if @user == current_user # changing the password invalidates the session respond_with @user do |f| f.html { flash[:notice] = "Thank you. Your account has been updated." redirect_to droom.dashboard_url } f.js { render partial: "droom/users/show/profile" } end else Rails.logger.warn "update failed: #{@user.errors.to_a.inspect}" respond_with @user end end |