-1
我有以下模式:在這種情況下remote_restaurant:的Rails:belongs_to的特定列
class User < ActiveRecord::Base
#method that I want to delete and replace with belongs_to
def restaurant
RemoteRestaurant.find_by_shortRD(self.INFO_SHORT_RD)
end
end
我怎樣才能添加belongs_to的?
你可以嘗試'belongs_to的:remote_restaurant,foreign_key:「shortRD''?我現在無法測試,我不記得確切的語法。 – zrl3dx
那個INFO_SHORT_RD常數是怎麼回事? – AJcodez