1
我正在用ROR製作一個非常簡單的網站。ROR上的不同實現
class Product < ActiveRecord::Base
belongs_to :category
has_many :photos
has_many :ordered_photos,
:class_name => 'Photo',
:order => 'name'
has_one :random_photo_1,
:class_name => 'Photo',
:order => 'RAND()'
def random_photo_2
Photo.find(:first, :conditions => { :product_id => self.id }, :order => 'RAND()')
end
end
在實現許多類的ActiveRecord的,我得到的疑問,我不理解那是什麼random_photo_1執行之間的random_photo_2方法不同。
P.S.我很抱歉我的英語。