LoginSignup
3
3

More than 5 years have passed since last update.

ruby2.2に上げたらwarning: circular argument reference - reflectionエラーが出る

Posted at
  • Ruby1.9.2-p326から2.2.3p173にアップ。Railsは3.2.17
    • こんなwarningが出ていてテストもこけている
…/.rbenv/versions/2.2.3/gemsets/3.3.x_version_up/gems/activerecord-3.2.17/lib/active_record/associations/has_many_association.rb:53: warning: circular argument reference - reflection
…/.rbenv/versions/2.2.3/gemsets/3.3.x_version_up/gems/activerecord-3.2.17/lib/active_record/associations/has_many_association.rb:57: warning: circular argument reference - reflection
…/.rbenv/versions/2.2.3/gemsets/3.3.x_version_up/gems/activerecord-3.2.17/lib/active_record/associations/has_many_association.rb:61: warning: circular argument reference - reflection
…/.rbenv/versions/2.2.3/gemsets/3.3.x_version_up/gems/activerecord-3.2.17/lib/active_record/associations/has_many_association.rb:80: warning: circular argument reference - reflection
NoMethodError: undefined method `name' for nil:NilClass
  • gemのコードを見てみるとreflection = reflectionでエラーになってるらしい
has_many_association.rb
 53         def has_cached_counter?(reflection = reflection)
 54           owner.attribute_present?(cached_counter_attribute_name(reflection))
 55         end
  • 以下のように書き換えると取り敢えずwarning出なくなりテストも通るようになる
has_many_association.rb
 53         def has_cached_counter?(reflection = reflection())
 54           owner.attribute_present?(cached_counter_attribute_name(reflection))
 55         end
  • rails3.2.22で修正されている。Railsは後程上げるので今回は取り敢えずこれでいいかな
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3