Would STI be a good solution for this?


#1

I’m using my ActionFlow plugin [1] to do workflow, and I’m storing
steps in the db. Right now I’ve created a WorkflowStep class that
just has a name field. It has a method which generates a particular
step from the name. The individual steps are plain ruby classes.

That’s worked fine so far, but now I need to associate some other data
with individual steps. For example a certain step has_many
:blog_posts or something. So I’m thinking of moving the steps into AR
classes, so I’d have something like this:

class WorkflowStep < ActiveRecord::Base
include ActionFlow::WorkflowStep
end

class NameStep < WorkflowStep
has_many :blog_posts

def passes?..
def action…
end

Now I can set up the associations I need.

There are several different steps so I’d be using STI. Is that a good
fit for my situation? I’ve never used STI before, so I’m not quite
sure if it’s right here. Sort of thinking it is though…if you’ve
got ideas for other approaches, I’d love to hear them. Thanks

Pat