Skip to content

Commit

Permalink
Don't persist invalid models
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlogic committed Jan 29, 2010
1 parent b39a71a commit 2d8887f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/aasm/persistence/active_record_persistence.rb
Expand Up @@ -180,7 +180,6 @@ def aasm_write_state_without_persistence(state)

module WriteState
# Writes <tt>state</tt> to the state column and persists it to the database
# using update_attribute (which bypasses validation)
#
# foo = Foo.find(1)
# foo.aasm_current_state # => :opened
Expand All @@ -193,7 +192,7 @@ def aasm_write_state(state)
old_value = read_attribute(self.class.aasm_column)
write_attribute(self.class.aasm_column, state.to_s)

unless self.save(false)
unless self.save
write_attribute(self.class.aasm_column, old_value)
return false
end
Expand Down

0 comments on commit 2d8887f

Please sign in to comment.