You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Car < ActiveRecord::Base
attr_accessible :state_event
state_machine :state, initial: :parked do
event :drive do
transition :parked => :driving
end
event :stop do
transition :driving => :parked
end
event :turn_right do
transition :driving => :moving_right
end
end
end
c = Car.create!
c.update_attributes({ state_event: :turn_right })
The last command will successfully save the car and update the state attribute to :turn_right, even though it should fail and return false, since a car cannot move from it's initial :parked state to :moving_right.
If I run:
c.state = :moving_right
c.save!
I will get the false value properly returned.
The text was updated successfully, but these errors were encountered:
This might be a related issue: pluginaweek/state_machine#327
Here I have a
Car
class:The last command will successfully save the car and update the state attribute to
:turn_right
, even though it should fail and return false, since a car cannot move from it's initial:parked
state to:moving_right
.If I run:
I will get the
false
value properly returned.The text was updated successfully, but these errors were encountered: