create with has_many through association gets NoMethodError (undefined method `name' for nil:NilClass)

前端 未结 4 751
野性不改
野性不改 2020-12-10 12:28

I\'m doing this tutorial and am stuck in the Tagging part. Basically I have articles that can have a list of tags. As one article can has multiple tags and vice versa, there

相关标签:
4条回答
  • 2020-12-10 13:00

    FYI, I can confirm this is an issue with ActiveRecord and Ruby 2.2. I was using ActiveRecord 3.2 and since changing to the 3-2-stable branch, the issue is gone. I believe this is fixed now in 4.x branches. I have raised an issue for this at https://github.com/rails/rails/issues/18991.

    0 讨论(0)
  • 2020-12-10 13:01

    I think there is a bug in activerecord 4.1.0 with has_cached_counter? and ruby 2.2. It was fixed on activerecord 4.1.2.

    I got it to work by switching rails versions from 4.1.0 to 4.1.2.

    0 讨论(0)
  • 2020-12-10 13:04

    Upgrade to Rails 4.0.13 (or later) or downgrading to Ruby 2.1.1 solves the problem.

    0 讨论(0)
  • 2020-12-10 13:05

    I got it to work by switching ruby versions. I was using ruby-head, which is ruby 2.2.0dev. Switched back to ruby-2.1.1, now it works without errors. Should've probably tried that earlier...

    Maybe this could help others facing similar errors.

    0 讨论(0)
提交回复
热议问题