If anybody on edge familiar with this could help, that would be “great”
I have different types of things I want to be “reviewable”. So, instead
of
having a slew of HABTM… this new Polymorphic Associations schtick
seemed
like the best solution. I have everything setup as I thought it should
be
(so I think)… but it doesn’t appear to be working correctly. Here is
my
setup:
User (table Clients: basic user stuff belonging to a functional
STI
relationship)
def User < Client
has_many :reviewings, :as => :reviewable, :dependent => true
has_many :reviews, :through => :reviewings
end
Review (table Reviews: id, rating, review)
def Review < AR:B
has_many :reviewings
end
Reviewing (table Reviewings: id, review_id, reviewable_id,
reviewable_type)
def Reviewing < AR:B
belongs_to :review
belongs_to :reviewable, :polymorphic => true
end
Now, within console:
u = User.find(:first)
my user stuffr = Review.find(:first)
my review stuffu.reviews << r
added r to u’s reviews
I check the “reviews” table, and the review is successfully entered…
however, there is no entry in “reviewables”.
I’ve played around with this for quite a while trying to debug why an
insert
isn’t happening into this table, but no dice.
Any insight into this would be greatly appreciated !
Dylan