给定模型:
class User
has_many :cars
has_many :foods
end
class Car
belongs_to :user
has_many :colors, :as => :owner
end
class Food
belongs_to :user
has_many :colors, :as => :owner
end
class Color
belongs_to :owner, :polymorphic => true # This can be Food or Car
end
我怎么能说在 Rails 3和Rails 3 上都有User
很多?那么 Rails 2 呢?Color
Car
Food