Forum: Ruby on Rails Would STI be a good solution for this?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Pat M. (Guest)
on 2007-02-02 22:24
(Received via mailing list)
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

class NameStep < WorkflowStep
  has_many :blog_posts

  def passes?...
  def action...

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

This topic is locked and can not be replied to.