Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError: undefined method `association' #154

Closed
PhilT opened this issue Sep 19, 2012 · 7 comments
Closed

NoMethodError: undefined method `association' #154

PhilT opened this issue Sep 19, 2012 · 7 comments

Comments

@PhilT
Copy link
Contributor

PhilT commented Sep 19, 2012

In IRB (Ruby 1.9.2-p290, Rails 3.0.17):

class CreateCategories < ActiveRecord::Migration
  def self.up
    create_table :categories do |t|
      t.string :name
      t.integer :parent_id
      t.integer :lft
      t.integer :rgt
      t.integer :depth # this is optional.
    end
  end

  def self.down
    drop_table :categories
  end
end

CreateCategories.up
class Category < ActiveRecord::Base
  acts_as_nested_set
end

parent = Category.create  name: 'parent'
child = Category.create  name: 'child'
child.move_to_child_of parent
NoMethodError: undefined method `association' for #<Category:0x00000008cd2758>
from activemodel-3.0.17/lib/active_model/attribute_methods.rb:392:in `method_missing'
from activerecord-3.0.17/lib/active_record/attribute_methods.rb:46:in `method_missing'
from awesome_nested_set-2.1.4/lib/awesome_nested_set/awesome_nested_set.rb:459:in `compute_level'
from awesome_nested_set-2.1.4/lib/awesome_nested_set/awesome_nested_set.rb:351:in `level'
from awesome_nested_set-2.1.4/lib/awesome_nested_set/awesome_nested_set.rb:500:in `block in set_depth!'
from activerecord-3.0.17/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
from activerecord-3.0.17/lib/active_record/transactions.rb:207:in `transaction'
from activerecord-3.0.17/lib/active_record/transactions.rb:231:in `transaction'
from awesome_nested_set-2.1.4/lib/awesome_nested_set/awesome_nested_set.rb:518:in `in_tenacious_transaction'
from awesome_nested_set-2.1.4/lib/awesome_nested_set/awesome_nested_set.rb:497:in `set_depth!'
from awesome_nested_set-2.1.4/lib/awesome_nested_set/awesome_nested_set.rb:643:in `block in move_to'
from activesupport-3.0.17/lib/active_support/callbacks.rb:414:in `_run_move_callbacks'
from activesupport-3.0.17/lib/active_support/callbacks.rb:94:in `run_callbacks'
from awesome_nested_set-2.1.4/lib/awesome_nested_set/awesome_nested_set.rb:576:in `move_to'
from awesome_nested_set-2.1.4/lib/awesome_nested_set/awesome_nested_set.rb:423:in `move_to_child_of'
from (irb):34
from railties-3.0.17/lib/rails/commands/console.rb:44:in `start'
from railties-3.0.17/lib/rails/commands/console.rb:8:in `start'
from railties-3.0.17/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'

This works in awesome_nested_set version: 2.0.2 (Just tested in IRB as well).

I'll test other versions and see when it was introduced. Could it be something to do with it being an older version of Rails?

UPDATE: Looks like it's working up to and including 2.1.3. So possibly introduced in 2.1.4.

@krsch
Copy link

krsch commented Sep 19, 2012

The same bug on rails 3.0.11 and ruby ee 1.8.7 p358 2012.02
Returning to awesome_nested_set 2.1.3 also helps.

@st-keller
Copy link

Same Problem with Rails 3.0.13:

2.1.4 shows the "undefined method `association'" (when we call 'save' or 'save!'),
2.1.3 just works fine

@parndt
Copy link
Collaborator

parndt commented Sep 26, 2012

Bonus points if anybody can bisect the commit that caused this and explain why :-)

@parndt
Copy link
Collaborator

parndt commented Sep 26, 2012

I've added 3.0, 3.1 and 3.2 as test targets on Travis CI which reveal the issue in 3.0.x:

http://travis-ci.org/#!/collectiveidea/awesome_nested_set/builds/2576086

@parndt
Copy link
Collaborator

parndt commented Sep 26, 2012

We have had to do similar workaround in the past for globalize3:

svenfuchs/globalize3@e8f82239

Perhaps that'll help someone.

@parndt parndt closed this as completed in 2307db1 Sep 26, 2012
@parndt
Copy link
Collaborator

parndt commented Sep 26, 2012

Solved it. I'll wait for the tests to pass and then release 2.1.5.

@parndt
Copy link
Collaborator

parndt commented Sep 26, 2012

Version 2.1.5 released to RubyGems. Thanks @PhilT @krsch @st-keller

We have far better regression testing, now :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants