controllers: refactor only param includes.
Add extra includes needed by the `only` param inside `respond_with`.
This commit is contained in:
@@ -24,7 +24,9 @@ class ForumPostsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
@forum_posts = ForumPost.paginated_search(params).includes(model_includes(params))
|
||||
@forum_posts = ForumPost.paginated_search(params)
|
||||
@forum_posts = @forum_posts.includes(:topic, :creator) if request.format.html?
|
||||
|
||||
respond_with(@forum_posts)
|
||||
end
|
||||
|
||||
@@ -68,14 +70,6 @@ class ForumPostsController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def default_includes(params)
|
||||
if ["json", "xml"].include?(params[:format])
|
||||
[]
|
||||
else
|
||||
[:topic, :creator]
|
||||
end
|
||||
end
|
||||
|
||||
def load_post
|
||||
@forum_post = ForumPost.find(params[:id])
|
||||
@forum_topic = @forum_post.topic
|
||||
|
||||
Reference in New Issue
Block a user