mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
Don't persist invalid models
This commit is contained in:
parent
b39a71a8b7
commit
2d8887fdcf
1 changed files with 1 additions and 2 deletions
|
@ -180,7 +180,6 @@ module AASM
|
|||
|
||||
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
|
||||
|
@ -193,7 +192,7 @@ module AASM
|
|||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue