Skip to content

Commit

Permalink
Fix incorrect previous_id setter.
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Nov 20, 2014
1 parent 97ca6cd commit 166f72c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/history_change.rb
Expand Up @@ -78,7 +78,11 @@ def next
end

def set_previous
self.previous = self.class.order(:id => :desc).find_by(:table_name => table_name, :remote_id => remote_id, :column_name => column_name)
self.previous = self.class
.where(:table_name => table_name, :remote_id => remote_id, :column_name => column_name)
.where("id < ?", id)
.order(:id => :desc)
.take
self.save!
end
end

0 comments on commit 166f72c

Please sign in to comment.