controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
This commit is contained in:
@@ -11,7 +11,7 @@ class PostsController < ApplicationController
|
||||
end
|
||||
else
|
||||
@post_set = PostSets::Post.new(tag_query, params[:page], params[:limit], raw: params[:raw], random: params[:random], format: params[:format])
|
||||
@posts = @post_set.posts = @post_set.posts.includes(model_includes(params)) if !@post_set.is_random?
|
||||
@posts = @post_set.posts = @post_set.posts.includes(:uploader) if !@post_set.is_random? && CurrentUser.is_moderator?
|
||||
respond_with(@posts) do |format|
|
||||
format.atom
|
||||
end
|
||||
@@ -98,14 +98,6 @@ class PostsController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml", "atom"].include?(params[:format])
|
||||
[]
|
||||
else
|
||||
(CurrentUser.user.is_moderator? ? [:uploader] : [])
|
||||
end
|
||||
end
|
||||
|
||||
def tag_query
|
||||
params[:tags] || (params[:post] && params[:post][:tags])
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user