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

Heroku only: undefined method `ancestry' for #<Model:0x007f1684d797a8> #243

Closed
etayluz opened this issue Oct 2, 2015 · 7 comments
Closed

Comments

@etayluz
Copy link

etayluz commented Oct 2, 2015

I'm seeing an issue on Heroku only (cannot reproduce locally):

A NoMethodError occurred in home#upload:
undefined method `ancestry' for #Model:0x007f1684d797a8

Method looks like this:
def anthem_upload
user = User.find_by(id: params[:user_id])
anthem = Anthem.create!(user_id: user.id, body:params[:post]) <-- happens here
...
ene

This method doesn't even call on .ancestry method - but the exception happens as soon as model is created.

Model looks like this:
class Anthem < ActiveRecord::Base
has_ancestry
...
end

@crazymykl
Copy link
Contributor

You did not migrate up your database (adding the ancestry column) in Heroku.

@kbrock
Copy link
Collaborator

kbrock commented Dec 5, 2015

Also of note, Heroku tends to loads all models at startup vs locally it tends to lazy load.
So on Heroku, an error in an unrelated model can be triggered and everything works locally.

To find these, I tend to go through the various controllers, so I'm exercising/loading all my code.
Also, I'll point my database.yml production environment to my test database and startup with RAILS_ENV=production

Best of luck

@kbrock
Copy link
Collaborator

kbrock commented Dec 21, 2015

@etayluz Any chance the error you are seeing is on github and I could kick the tires?
Thanks

@djass
Copy link

djass commented Mar 18, 2016

I have also "NoMethodError: undefined method `ancestry' " when I try to save my object in database. Of course I migrated up my database.
I done that :
a = Component.new
a.save

And I have this error : NoMethodError: undefined method `ancestry' for #Component:0x00000005c95f68

My model is like this :
class Component < ActiveRecord::Base
has_ancestry
end

My migration is like this :
class AddAncestryToComponent < ActiveRecord::Migration
def change
add_column :components, :acst, :integer
add_index :components, :acst
end
def down

  remove_column :components, :acst
  remove_index :components, :acst

end
end

Please help me, what I done wrong ?

@crazymykl
Copy link
Contributor

The column should be called ancestry, and it should a string (or a text).

@crazymykl
Copy link
Contributor

The column should be called ancestry (or you can use the ancestry_column option when calling has_ancestry), and it should a string (or a text).

@kbrock
Copy link
Collaborator

kbrock commented Aug 9, 2017

Please reopen if this is still an issue.

@kbrock kbrock closed this as completed Aug 9, 2017
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