2014-11-02 17:57:37 +01:00
|
|
|
class UserController < ApplicationController
|
|
|
|
def show
|
2014-12-14 12:13:05 +01:00
|
|
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first
|
2014-11-12 20:40:24 +01:00
|
|
|
@answers = @user.answers.reverse_order.paginate(page: params[:page])
|
2014-12-08 15:23:04 +01:00
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.js
|
|
|
|
end
|
2014-11-02 17:57:37 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
2014-11-11 19:53:25 +01:00
|
|
|
authenticate_user!
|
2014-11-03 13:21:41 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2014-11-11 19:53:25 +01:00
|
|
|
authenticate_user!
|
2014-12-01 20:47:10 +01:00
|
|
|
user_attributes = params.require(:user).permit(:display_name, :motivation_header, :website, :location, :bio)
|
2014-11-11 20:20:00 +01:00
|
|
|
unless current_user.update_attributes(user_attributes)
|
2014-11-29 22:34:11 +01:00
|
|
|
flash[:error] = 'fork it'
|
2014-11-11 20:20:00 +01:00
|
|
|
end
|
2014-11-03 13:21:41 +01:00
|
|
|
redirect_to edit_user_profile_path
|
2014-11-02 17:57:37 +01:00
|
|
|
end
|
2014-12-08 17:03:06 +01:00
|
|
|
|
|
|
|
def followers
|
|
|
|
@title = 'Followers'
|
2014-12-14 12:13:05 +01:00
|
|
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first
|
2014-12-08 17:10:09 +01:00
|
|
|
@users = @user.followers.reverse_order.paginate(page: params[:page])
|
2014-12-08 19:48:12 +01:00
|
|
|
@type = :friend
|
2014-12-08 17:03:06 +01:00
|
|
|
render 'show_follow'
|
|
|
|
end
|
|
|
|
|
2014-12-08 19:51:34 +01:00
|
|
|
def friends
|
2014-12-08 17:03:06 +01:00
|
|
|
@title = 'Following'
|
2014-12-14 12:13:05 +01:00
|
|
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first
|
2014-12-08 17:10:09 +01:00
|
|
|
@users = @user.friends.reverse_order.paginate(page: params[:page])
|
2014-12-08 19:48:12 +01:00
|
|
|
@type = :friend
|
2014-12-08 17:03:06 +01:00
|
|
|
render 'show_follow'
|
|
|
|
end
|
2014-12-19 22:34:24 +01:00
|
|
|
|
|
|
|
def questions
|
|
|
|
@title = 'Questions'
|
|
|
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first
|
2014-12-19 23:12:19 +01:00
|
|
|
@questions = @user.questions.where(author_is_anonymous: false).reverse_order.paginate(page: params[:page])
|
2014-12-19 22:34:24 +01:00
|
|
|
end
|
2014-11-02 17:57:37 +01:00
|
|
|
end
|