【发布时间】:2014-01-06 09:56:22
【问题描述】:
我有以下型号:
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 :remote_restaurant?
【问题讨论】:
-
你能试试
belongs_to :remote_restaurant, foreign_key: 'shortRD'吗?我现在无法测试它,我不记得确切的语法。 -
INFO_SHORT_RD 常量是怎么回事?
标签: ruby-on-rails ruby orm model relation