同じモデルの複数のプロパティを持つ方法を見つけるのに苦労しています。私はこの構造を持っています:
class Image < ActiveRecord::Base
attr_accessible :name, :content_type
end
class MenuImage < ActiveRecord::Base
belongs_to :image
belongs_to :menu
end
class Menu < ActiveRecord::Base
has_many :menu_images
has_many :images, :through => :menu_images
has_one :image, :as => :thumbnail_image
attr_accessible :thumbnail_image_id
end
@menu.images
とを使用して画像にアクセスできるようにしたい@menu.thumbnail_image
。コードhas_one :image, :as => :thumbnail_image
は私が取得しようとしているものの例です。