Ruby on rails 3 Rails 4通过关联的attr_访问器不工作
我一直在将我的应用程序从rails 3升级到rails 4,其中我有一个模型Ruby on rails 3 Rails 4通过关联的attr_访问器不工作,ruby-on-rails-3,ruby-on-rails-4,Ruby On Rails 3,Ruby On Rails 4,我一直在将我的应用程序从rails 3升级到rails 4,其中我有一个模型user.rb,其中包含如下关联 轨道3: has_many :accounts, :conditions => proc { "accounts.year_id = #{current_year_id}" } 其中,当前\u年\u id是获取者和设置者用户方法和 从rails 3开始,它工作得很好 在Rails 4中,我将其更改为: has_many :accounts, -> { where( ye
user.rb
,其中包含如下关联
轨道3:
has_many :accounts, :conditions => proc { "accounts.year_id = #{current_year_id}" }
其中,当前\u年\u id
是获取者
和设置者
用户方法和
从rails 3开始,它工作得很好
在Rails 4中,我将其更改为:
has_many :accounts, -> { where( year_id: current_year_id ) }
现在,当前\u year\u id成为attr\u访问器
问题是,它为Account::ActiveRecord\u Relation:0x00000011e13438抛出了未定义的局部变量或方法“current\u year\u id”