# Keeping separate lists of parent objects

**URL:** <https://www.ruby-forum.com/t/keeping-separate-lists-of-parent-objects/158730>\
**Category:** Rails\
**Created:** [January 27, 2009, 12:02pm UTC](https://www.ruby-forum.com/t/keeping-separate-lists-of-parent-objects/158730 "2009-01-27T12:02:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2009, 12:02pm UTC](https://www.ruby-forum.com/t/keeping-separate-lists-of-parent-objects/158730/1 "2009-01-27T12:02:27Z")

</div>

OK here’s the deal. I have a Verification object that I want to use  
to allow users to verify data (Posts, Pics, Addresses, etc). Each  
Post, Address, etc object will be related 1:1 to a Verification  
object.

But I want to have the Verification keep 3 separate lists of users. I  
have generated the following migration code, but i don’t think it’s  
going to work properly:  
def self.up  
create\_table :verifications do |t|  
t.references :voted\_real  
t.references :voted\_fake  
t.references :flagged

```
  t.timestamps
end

```

See I want voted\_real to be a list of users who have voted “Real”,  
similarly :voted\_fake should be a list of users who have voted “Fake”  
and flagged to be a list of users who have “flagged” content (as  
offensive, inappropriate, etc).

So you see, the standard options for ActiveRecord Associations will  
not suffice (as far as I can tell).

Can someone help me out here? I maybe just need a different design or  
maybe I can use polymorphic associations, but I’m not sure yet. I  
think I can use polymorphic associations to associate the  
Verifications to the other objects, but not to accomplish what I want  
to do with the Verification to User relationship(s).

I appreciate your help!!

-Steve

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 27, 2009, 8:08pm UTC](https://www.ruby-forum.com/t/keeping-separate-lists-of-parent-objects/158730/2 "2009-01-27T20:08:37Z")

</div>

I think I’ve figured it out. Sorry for posting what amounts to an  
architectural question here, I’m guessing that’s not really what this  
board is for.

For anyone curious about what I decided to do:

I haven’t totally decided yet. I might trash the idea of a  
“Verification” class, and instead opt for a Vote class:  
Vote:  
type  
user

Then it would be a polymorphic association like this:  
class Vote \< ActiveRecord::Base  
belongs\_to :voteable, :polymorphic =\> true  
end

class Post \< ActiveRecord::Base  
has\_many :votes, :as =\> :voteable  
end

class Product \< ActiveRecord::Base  
has\_many :votes, :as =\> :voteable  
end

* * *

Otherwise if I stick with my verification class, I think I’ll need to  
do some sort of HMABT relationship, and I honestly don’t see the  
point. So yeah. I’ll probably just do the Vote thing.

Cheers!
