Some small helpers to
- access all states
- access all events
- define all status? methods
for rails state_machine plugin (for former acts_as_state_machine).
(this will not work if you got multiple status fields).
Usage
movie.online? movie.banned? ... f.select(:status,Movie.states)
Install
#lib/status_helper.rb module StatusHelper def self.included(base) base.class_eval do def self.states; state_machines['status'].states; end def self.events; state_machines['status'].events.keys; end states.each {|state| define_method("#{state}?"){status == state} } end end end #your model class Movie include StatusHelpers end