Displaying 2 results from an estimated 2 matches for "reviewable_typ".
Did you mean:
reviewable_type
2006 Feb 09
2
Polymorphic Associations
...iewings, :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 stuff
>> r = Review.find(:first)
my review stuff
>> u.reviews << r
added r to u'...
2008 Jan 21
13
has_many with different primary key
I''ve got quite the ActiveRecord challenge, any help would be
appreciated.
In my current project Companies can have many reviews.
class Company < ActiveRecord::Base
has_many :reviews, :as => :reviewable
end
However, my company table, I have two different IDs to identify my
company.
id - This is the typical id we use for normal stuff
other_company_id - This is the id we use