私のアプリで2つのRailscasts:http://railscasts.com/episodes/262-trees-with-ancestryとhttp://railscasts.com/episodes/154-polymorphic-associationを一緒に転がそうとしています。 マイモデル: class Location < ActiveRecord::Base
has
は、以下の多型の関係 class Person
has_many :photos, :as => :attachable
end
class Animal
has_many :photos, :as => :attachable
end
class Photo
belongs_to :attachable, :polymorphic => true
en
Ruby on Railsで2種類の曲を聴くことができるアプリを作成しています。私は、ユーザーが聞いている各曲(および種類)をトラッキングしたい。ユーザーはuser_songまたはmaster_songを聞くことができます。 私の最初の考えは、多形性の関連付けを使用することでした。 まず、私のユーザモデルは次のようになります。 class User < ActiveRecord::Base
ha