Class: UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- UsersController
- Defined in:
- app/controllers/users_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/users_controller.rb', line 22 def create @user = User.new(params[:user]) if @user.save flash[:notice] = t :registration_successful_flash redirect_to root_path else render :action => 'new' end end |
#edit ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/controllers/users_controller.rb', line 32 def edit @user = get_user_from_params(params) unless @user.can_be_modified_by(current_user) flash[:notice] = t(:access_denied_flash) @user.nil? ? redirect_to(root_path) : redirect_to("/users/#{@user.username}/edit") end end |
#index ⇒ Object
10 11 12 |
# File 'app/controllers/users_controller.rb', line 10 def index @users = User.paginate :page => params[:page] end |
#new ⇒ Object
18 19 20 |
# File 'app/controllers/users_controller.rb', line 18 def new @user = User.new end |
#show ⇒ Object
14 15 16 |
# File 'app/controllers/users_controller.rb', line 14 def show @user = get_user_from_params(params) end |
#update ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/users_controller.rb', line 40 def update # dont you params here, should know the username @user = User.find(params['id']) if @user.can_be_modified_by(current_user) if @user.update_attributes(params['user']) flash[:notice] = t(:profil_change_success_flash) redirect_to root_path else render :action => 'edit' end else @user = current_user flash[:notice] = t(:access_denied_flash) render :action => 'edit' end end |