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
CodeMeister edited this page Feb 28, 2023
·
1 revision
StateGate does not work within abstract classes.
When defining a state_gate within the abstract class, it analyses the table structure, including any attribute aliases - which, of course, are not yet defined.
StateGate should be defined directly within the descendant class that has a supporting database table.
failing example:
class User < ActiveRecord::Base
self.abstract_class = true
include StateGate
state_gate :status do
state :pending
state :active
end
end
class Member < User
self.table_name = 'members'
end
#=> <ActiveRecord::TableNotSpecified: User has no table configured
passing example:
class User < ActiveRecord::Base
self.abstract_class = true
include StateGate
end
class Member < User
self.table_name = 'members'
state_gate :status do
state :pending
state :active
end
end