FIX: You could update a topic to have a title that's too short if the TextCleaner

removed extra characters. Additionally, updating the title will not return an error
message to the client app if the operation fails (rather than failing silently.)
This commit is contained in:
Robin Ward
2013-05-31 15:22:34 -04:00
parent 2982c23265
commit d23ef1d090
6 changed files with 39 additions and 5 deletions

View File

@ -62,14 +62,19 @@ class TopicsController < ApplicationController
topic.archetype = "regular" if params[:archetype] == 'regular'
end
success = false
Topic.transaction do
topic.save
topic.change_category(params[:category])
success = topic.save
topic.change_category(params[:category]) if success
end
# this is used to return the title to the client as it may have been
# changed by "TextCleaner"
render_serialized(topic, BasicTopicSerializer)
if success
render_serialized(topic, BasicTopicSerializer)
else
render_json_error(topic)
end
end
def similar_to