Code Cleanup: Usage of Polymorphic User instead of ExternalUser and InternalUser
Renamed requestor_user_id -> user_id Index of request_for_comments now returns the n (5?) newest requests per user. Solved via sliding windows in postgres, code added to model. Added route to /my_request_for_comments/ that shows all requests for the current user. Changed view from ERB to slim
This commit is contained in:
@ -11,11 +11,15 @@ class RequestForCommentsController < ApplicationController
|
||||
# GET /request_for_comments
|
||||
# GET /request_for_comments.json
|
||||
def index
|
||||
# @request_for_comments = RequestForComment.all
|
||||
@request_for_comments = RequestForComment.all.order('created_at DESC').limit(50)
|
||||
@request_for_comments = RequestForComment.last_per_user(2).paginate(page: params[:page])
|
||||
authorize!
|
||||
end
|
||||
|
||||
def get_my_comment_requests
|
||||
@request_for_comments = RequestForComment.where(user_id: current_user.id).order('created_at DESC').paginate(page: params[:page])
|
||||
render 'index'
|
||||
end
|
||||
|
||||
# GET /request_for_comments/1
|
||||
# GET /request_for_comments/1.json
|
||||
def show
|
||||
@ -66,6 +70,6 @@ class RequestForCommentsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def request_for_comment_params
|
||||
params.require(:request_for_comment).permit(:exercise_id, :file_id, :requested_at).merge(requestor_user_id: current_user.id, user_type: current_user.class.name)
|
||||
params.require(:request_for_comment).permit(:exercise_id, :file_id, :requested_at).merge(user_id: current_user.id, user_type: current_user.class.name)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user