mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
3da275c439
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)
11 lines
246 B
Ruby
11 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
|