Browse files

Fix editing search result comments.

  • Loading branch information...
1 parent 23dc14a commit b05b0f350020423ee92359a5e1cc8008f1d3bd06 @mpereira mpereira committed Oct 19, 2011
Showing with 13 additions and 5 deletions.
  1. +13 −5 app/controllers/comments_controller.rb
View
18 app/controllers/comments_controller.rb
@@ -166,22 +166,30 @@ def current_scope
end
def find_scope
- @question = Question.by_slug(params[:question_id])
- @answer = @question.answers.find(params[:answer_id]) unless params[:answer_id].blank?
- @search_result = SearchResult.find(params[:search_result_id])
+ if params[:question_id].present?
+ if @question = Question.find_by_slug_or_id(params[:question_id])
+ if params[:answer_id]
+ @answer = @question.answers.find(params[:answer_id])
+ elsif params[:search_result_id]
+ @search_result =
+ @question.search_results.find(params[:search_result_id])
+ end
+ end
+ end
end
def scope
@search_result || @answer || @question
end
def full_scope
- unless @answer.nil?
+ if @answer
[@question, @answer]
+ elsif @search_result
+ [@question, @search_result]
else
[@question]
end
end
helper_method :full_scope
-
end

0 comments on commit b05b0f3

Please sign in to comment.