1
0
Fork 0
forked from OpenNeo/impress
impress/app/controllers/users_controller.rb

41 lines
986 B
Ruby
Raw Normal View History

2010-11-06 09:15:10 -07:00
class UsersController < ApplicationController
2011-07-20 12:16:22 -07:00
before_filter :find_and_authorize_user!, :only => [:update]
2010-11-06 09:15:10 -07:00
def top_contributors
@users = User.top_contributors.paginate :page => params[:page], :per_page => 20
end
2011-07-20 12:16:22 -07:00
def update
2011-07-22 11:02:04 -07:00
success = @user.update_attributes params[:user]
respond_to do |format|
format.html {
if success
flash[:success] = "Settings successfully saved"
redirect_back! user_closet_hangers_path(@user)
else
flash[:alert] = "Error saving user settings: #{@user.errors.full_messages.to_sentence}"
end
}
format.json {
if success
render :json => true
else
render :json => {:errors => @user.errors.full_messages}, :status => :unprocessable_entity
end
}
end
2011-07-20 12:16:22 -07:00
end
protected
def find_and_authorize_user!
if current_user.id == params[:id].to_i
@user = current_user
else
raise AccessDenied
end
end
2010-11-06 09:15:10 -07:00
end
2011-07-20 12:16:22 -07:00