Another Ruby-on-Rails Gripe: “acts_as_list”

Okay, working on my web app using Ruby on Rails, and I just encountered a new gripe. Now, it may be a newbie gripe, or it may be a genuine issue — I’m not so sure. I’m looking for help if anyone’s got it, but I’m not finding it in either of the $40 books on Rails I’ve got at hand.

Let me first set the stage. In application models (this is “models” as in “Model-View-Controller”), you will often have a relationship between two models. And these models can be represented in a number of ways: for instance, one model might contain a list of instances of another model. Unfortunately, the coding for that model is done in the model within the list, not the model having the list. Which means, as far as I can tell, that every model can only be in a single list. And I’ve encountered a modelling situation where I want a model to be in multiple lists.

So how do you solve this in rails? For the time being, I’ve created intermediary models anywhere I want there to be a list (similar to using a model to represent a join). There’s got to be a better solution.

This entry was posted in To Be Categorized and tagged . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. Posted February 19, 2007 at 12:00 AM | Permalink

    Temporary solution: overwrite the nice auto-generated method provided by has_many and acts_as_list with a one-liner query that returns a list of the item.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">