I'm seeing an issue on Heroku only with the ancestry gem (cannot reproduce locally): https://github.com/stefankroes/ancestry
A NoMethodError occurred in home#upload: undefined method `ancestry' for #
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
Here is the logs:
A NoMethodError occurred in home#anthem_upload: undefined method `ancestry' for #<Anthem:0x007f1684d58b98> app/controllers/home_controller.rb:335:in `anthem_upload'
You must run the migration to add the method ancestry
to your model:
heroku run rake db:migrate
Of course assuming your app works at development. If not you can generate the migration with
rails g migration add_ancestry_to_[table] ancestry:string
Taken from ancestry
Edited
After read your comments, I did try my hypothesis. Adding the ancestry
gem to a project that doesn't need, and them adding has_ancestry
to the model Task
, without migrations, at the console I got:
Loading development environment (Rails 4.2.2)
~/ (development) > Task.new
=> #<Task:0x00000008a3d088> {
:id => nil,
:project_id => nil,
:name => nil,
:description => nil,
:points_budget => nil,
:created_at => nil,
:updated_at => nil
}
~/ (development) > Task.new.save
(0.2ms) BEGIN
(0.2ms) ROLLBACK
NoMethodError: undefined method `ancestry' for #<Task:0x00000008a9c998>
from /home/alejandro/.rvm/gems/ruby-2.2.2@rails4/gems/activemodel-4.2.2/lib/active_model/attribute_methods.rb:433:in `method_missing'
~/ (development) > Task.new.validate
NoMethodError: undefined method `ancestry' for #<Task:0x00000008ad1210>
from /home/alejandro/.rvm/gems/ruby-2.2.2@rails4/gems/activemodel-4.2.2/lib/active_model/attribute_methods.rb:433:in `method_missing'
The same error you got. Of course, I'm at development. You must try something like this at heroku with: heroku run rails console
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With