Class: Droom::UsersController

Inherits:
EngineController show all
Defined in:
app/controllers/droom/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#editObject



16
17
18
# File 'app/controllers/droom/users_controller.rb', line 16

def edit
  respond_with @user
end

#indexObject



12
13
14
# File 'app/controllers/droom/users_controller.rb', line 12

def index
  @everyone = Droom::Person.all + Droom::User.unpersoned
end

#updateObject

This has to handle small preference updates over js and large account-management forms over html.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/droom/users_controller.rb', line 22

def update
  if @user.update_attributes(params[:user])
    (@user, :bypass => true) if @user == current_user        # changing the password invalidates the session unless we refresh it with the new one
    respond_to do |format|
      format.js { 
        partial = params[:response_partial] || "confirmation"
        render :partial => "droom/users/#{partial}"
      }
      format.html {
        if current_user.admin? && @user != current_user
          flash[:notice] = t(:user_updated, :name => @user.name)
        else
          flash[:notice] = t(:your_preferences_saved)
        end
        redirect_to droom.dashboard_url
      }
    end
  else
    render :edit
  end
end