Rail3到Rails 4;改变条件到哪里

时间:2014-05-08 17:38:15

标签: ruby-on-rails ruby-on-rails-4 models

升级到Rail4时,我将条件更改为模型中的位置,但我现在收到语法错误(语法错误,意外'}',期待关键字_end)

has_many :businesses, through: :business_admins, { where business_admins: { state: 'accepted'} }

1 个答案:

答案 0 :(得分:0)

将其更改为:

has_many :businesses, 
  -> { where(business_admins: { state: 'accepted'}) }, 
  through: :business_admins

另见Rails documentation