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