associations are not working on fetching object #41

Closed
amuntasim opened this Issue May 5, 2012 · 1 comment

Projects

None yet

3 participants

@amuntasim

here are my models:

class A < ActiveRecord::Base
is_impressionable :counter_cache => true
has_many :comments
end

class B < ActiveRecord::Base
is_impressionable :counter_cache => true
belongs_to A
end

now it wont work:
b = B.first
b.a.comments shows undefined method comments for A.
but b.a works fine.

if is_impressionable class method is been called after all association declaration then it works fine.

class B < ActiveRecord::Base

belongs_to A
is_impressionable :counter_cache => true

end

then all will work fine

NB: I am using rails 3.2.2 with impressionist 1.1.1

@sourcec0de

I just put up a small example on GIST. It works but only for individual Active Record Objects.

#45

Also you might want to check if your migrations have been completed
sounds like you might not have an id column in one of your tables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment