I have been upgrading my app from rails 3 to rails 4 in which i have a model user.rb
with associations like
Rails 3:
has_many :accounts, :conditions => proc { "accounts.year_id = #{current_year_id}" }
where current_year_id
is getter
& setter
methods of user
and It was working fine since rails 3
In Rails 4, i changed it to:
has_many :accounts, -> { where( year_id: current_year_id ) }
now, current_year_id become an attr_accessor
.
The problem is, it throws undefined local variable or method 'current_year_id' for Account::ActiveRecord_Relation:0x00000011e13438
Aucun commentaire:
Enregistrer un commentaire