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
If I validate with the same method across (at least) two different states
the validation isn't called.
require 'active_record'
require 'state_machine'
ActiveRecord::Base.
establish_connection(:adapter => 'sqlite3', :database => ':memory:')
ActiveRecord::Base.connection.create_table( :models ) do |t|
t.string :property
t.string :state
end
class Model < ActiveRecord::Base
def property_is_nice
fail
end
state_machine :state, :initial => :foo do
state :a do
validate :property_is_nice
end
state :b do
validate :property_is_nice
end
event :to_a do
transition :foo => :a
end
event :to_b do
transition :a => :b
end
end
end
@foo = Model.create property: "nice"
@foo.to_a #=> true (doesn't fail!)
@foo.state # => "a"
Is this a known bug?
This does not happen if I use validates style validations like
state :a do
validates :property => :nice
end
state :b do
validates :property => :nice
end
The text was updated successfully, but these errors were encountered:
Here a minimal example to be run in irb.
If I validate with the same method across (at least) two different states
the validation isn't called.
Is this a known bug?
This does not happen if I use validates style validations like
The text was updated successfully, but these errors were encountered: