diff --git a/app/models/story.rb b/app/models/story.rb index fb08bf8e54..5a31d41d24 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -47,9 +47,12 @@ class Story < Issue def self.create_and_position(params) attribs = params.select{|k,v| k != 'prev_id' and k != 'id' and Story.column_names.include? k } attribs = Hash[*attribs.flatten] - s = Story.new(attribs) - s.move_after(params['prev_id']) if s.save - return s + + Story.new(attribs).tap do |s| + if s.save + s.move_after(params['prev_id']) + end + end end def self.find_all_updated_since(since, project_id) @@ -132,12 +135,13 @@ class Story < Issue def update_and_position!(params) attribs = params.select{|k,v| k != 'id' and Story.column_names.include? k } attribs = Hash[*attribs.flatten] - result = journalized_update_attributes attribs - if result and params[:prev] - reload - move_after(params[:prev]) + + journalized_update_attributes(attribs).tap do |result| + if result and params[:prev] + reload + move_after(params[:prev]) + end end - result end def rank=(r)