2013-08-21 95 views
0

我有两个表table1和table2 with has_many belongs_to关系(table1有很多table2和table2属于table1)我写这样的值table2.table1.where(.....) 但我有以下错误未定义的方法`哪里'在红宝石轨道协会

NoMethodError: undefined method `where' for #<table1:0xc59764c> 

回答

2

如果table2属于table1,然后调用table2.table1会给你table1类型的单个对象。您不能在单个对象上调用where(这样做也没有意义),只能在表或关系上调用。