1
我有这个在我的架构:如何在Ruby on Rails中使对象成为模型的属性?
create_table "robots_matches", :force => true do |t|
t.integer "robot_id"
t.integer "match_id"
,我想我希望能够从我的robots_match模型中加载一个机器人比赛,所以我可以做这样的事情: robots_match.find(:身份证。).get_robot()名称
我在robots_matches模型的尝试是这样的:
def get_robot
Robot.find(this.id)
end
我超新轨道,所以欢迎随时纠正我的架构决策。
然后,你可以做查询,请出示您的模型。 – 2012-03-24 14:17:03