rails/activerecord/test/models/treasure.rb
beerlington 3da275c439 Accept belongs_to assoc. keys in ActiveRecord queries
Allows you to specify the model association key in a belongs_to
relationship instead of the foreign key.

The following queries are now equivalent:

Post.where(:author_id => Author.first)
Post.where(:author => Author.first)

PriceEstimate.where(:estimate_of_type => 'Treasure', :estimate_of_id => treasure)
PriceEstimate.where(:estimate_of => treasure)
2012-09-11 14:11:51 -04:00

12 lines
246 B
Ruby

class Treasure < ActiveRecord::Base
has_and_belongs_to_many :parrots
belongs_to :looter, :polymorphic => true
has_many :price_estimates, :as => :estimate_of
accepts_nested_attributes_for :looter
end
class HiddenTreasure < Treasure
end