[Rails] Re: extracting a portion of a model to a separate file
Gentlemen thanks for having this conversation. Was pulling my hair out
trying to get state_machine to work with a mixin. I need to define
state_machines behaviors unique to each client while keeping a single
code base. I ended up using opening up the class like Maren suggested.
class OnDemandWorkorderWorkflow < Workflow
belongs_to :workorder
attr_accessible :type, :state, :workorder_id
require
"#{Rails.root}/lib/clients/#{CUSTOMER}/workflows/#{FILE_REFERENCE}_on_demand_workorder_workflow"
end
required file looks like this:
class OnDemandWorkorderWorkflow < Workflow
state_machine :state, :initial => :new do
.......
# lots of events and transitions
.......
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home