1
我有兩個模型,Like和Photo。Rails 3 - 模型問題,外鍵
class Like < ActiveRecord::Base
belongs_to :photo, :class_name => "DataLike", :foreign_key => "photo_id"
end
class Photo < ActiveRecord::Base
has_many :likes
end
現在我試圖執行此查詢:
query = Like.select(:photo_id).joins(:photo).count
但我仍然得到這個錯誤:
uninitialized constant Like::DataLike
誰能幫助我,請我在做什麼錯?
謝謝你這麼多