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
on 2009-01-27 12:02
on 2009-01-27 20:08
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!