Skip to content

Commit

Permalink
update last target after editing comments
Browse files Browse the repository at this point in the history
Signed-off-by: David A. Cuadrado <krawek@gmail.com>
  • Loading branch information
dcu committed Apr 12, 2010
1 parent c75d02c commit d2bbb23
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/controllers/answers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ def update
@answer.updated_by = current_user

if @answer.valid? && @answer.save
Question.update_last_target(@question.id, @answer)

flash[:notice] = t(:flash_notice, :scope => "answers.update")

Magent.push("actors.judge", :on_update_answer, @answer.id)
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def update
@comment = Comment.find(params[:id])
@comment.body = params[:body]
if @comment.valid? && @comment.save
if question_id = @comment.question_id
Question.update_last_target(question_id, @comment)
end

flash[:notice] = t(:flash_notice, :scope => "comments.update")
format.html { redirect_to(params[:source]) }
format.json { render :json => @comment.to_json, :status => :ok}
Expand Down
5 changes: 4 additions & 1 deletion app/views/questions/_question.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
-owner = nil
-if question.last_target.present?
-last_target = question.last_target
-owner= last_target.user
-if last_target.respond_to?(:updated_by) && last_target.updated_by.present?
-owner= last_target.updated_by
-else
-owner= last_target.user
-else
-last_target = question
-owner = question.user
Expand Down

0 comments on commit d2bbb23

Please sign in to comment.