controllers: standardize request format checks.
This commit is contained in:
@@ -7,9 +7,9 @@ class CommentsController < ApplicationController
|
||||
def index
|
||||
params[:group_by] ||= "comment" if params[:search].present?
|
||||
|
||||
if params[:group_by] == "comment" || request.format == Mime::Type.lookup("application/atom+xml")
|
||||
if params[:group_by] == "comment" || request.format.atom?
|
||||
index_by_comment
|
||||
elsif request.format == Mime::Type.lookup("text/javascript")
|
||||
elsif request.format.js?
|
||||
index_for_post
|
||||
else
|
||||
index_by_post
|
||||
|
||||
@@ -20,7 +20,7 @@ class ForumTopicsController < ApplicationController
|
||||
|
||||
def index
|
||||
params[:search] ||= {}
|
||||
params[:search][:order] ||= "sticky" if request.format == Mime::Type.lookup("text/html")
|
||||
params[:search][:order] ||= "sticky" if request.format.html?
|
||||
params[:limit] ||= 40
|
||||
|
||||
@forum_topics = ForumTopic.paginated_search(params).includes(model_includes(params))
|
||||
@@ -29,7 +29,7 @@ class ForumTopicsController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
if request.format == Mime::Type.lookup("text/html")
|
||||
if request.format.html?
|
||||
@forum_topic.mark_as_read!(CurrentUser.user)
|
||||
end
|
||||
@forum_posts = ForumPost.search(:topic_id => @forum_topic.id).reorder("forum_posts.id").paginate(params[:page])
|
||||
|
||||
@@ -21,7 +21,7 @@ class PostsController < ApplicationController
|
||||
def show
|
||||
@post = Post.find(params[:id])
|
||||
|
||||
if request.format == Mime::Type.lookup("text/html")
|
||||
if request.format.html?
|
||||
@comments = @post.comments
|
||||
@comments = @comments.includes(:creator)
|
||||
@comments = @comments.includes(:votes) if CurrentUser.is_member?
|
||||
|
||||
Reference in New Issue
Block a user