retrospring/app/controllers/user_controller.rb

20 lines
504 B
Ruby
Raw Normal View History

2014-11-02 17:57:37 +01:00
class UserController < ApplicationController
def show
2014-11-02 18:16:47 +01:00
@user = User.find_by_screen_name!(params[:username])
2014-11-12 20:40:24 +01:00
@answers = @user.answers.reverse_order.paginate(page: params[:page])
2014-11-02 17:57:37 +01:00
end
def edit
authenticate_user!
2014-11-03 13:21:41 +01:00
end
def update
authenticate_user!
2014-11-29 22:34:11 +01:00
user_attributes = params.require(:user).permit(:display_name, :motivation_header)
unless current_user.update_attributes(user_attributes)
2014-11-29 22:34:11 +01:00
flash[:error] = 'fork it'
end
2014-11-03 13:21:41 +01:00
redirect_to edit_user_profile_path
2014-11-02 17:57:37 +01:00
end
end