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

Getting NoMethodError: undefined method `stamper' on Rails 5.1.2 #22

Open
blimey85 opened this issue Jul 4, 2017 · 3 comments
Open
Labels

Comments

@blimey85
Copy link

blimey85 commented Jul 4, 2017

Running Rails 5.1.2 on Ruby 2.4.1 and getting this:

rails aborted!
StandardError: An error has occurred, all later migrations canceled:

undefined method `stamper' for #<Class:0x007fddce0423c0>
Did you mean?  stamper_class
/Users/gary/.rbenv/versions/2.4.1/gemsets/dp/gems/activerecord-5.1.2/lib/active_record/dynamic_matchers.rb:22:in `method_missing'
/Users/gary/.rbenv/versions/2.4.1/gemsets/dp/bundler/gems/activerecord-userstamp-871d822ffda4/lib/active_record/userstamp/stampable.rb:95:in `has_stamper?'
/Users/gary/.rbenv/versions/2.4.1/gemsets/dp/bundler/gems/activerecord-userstamp-871d822ffda4/lib/active_record/userstamp/stampable.rb:109:in `set_updater_attribute'
/Users/gary/.rbenv/versions/2.4.1/gemsets/dp/gems/activesupport-5.1.2/lib/active_support/callbacks.rb:413:in `block in make_lambda'

I thought this might be related to the initializer but I commented that out and get the same thing. This is using the master branch of the gem. Without specifying that I was pulling version 2.1.1 which appears to be very old.

I couldn't run tests on 2.4.1 but I figured running them on 2.4.0 would be sufficient. I'm using rbenv and my copy of 2.4.1 is just for my project... I do test stuff in 2.4.0. Anyway, here's the output of RSpec:

 ~/.r/v/2/g/d/b/g/activerecord-userstamp-871d822ffda4   master ±  rspec
-- create_table(:users, {:force=>true})
   -> 0.0192s
-- create_table(:people, {:force=>true})
   -> 0.0003s
-- create_table(:posts, {:force=>true})
   -> 0.0003s
-- create_table(:comments, {:force=>true})
   -> 0.0004s
-- create_table(:tags, {:force=>true})
   -> 0.0003s
-- create_table(:post_tags, {:force=>true})
   -> 0.0003s
Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}

Randomized with seed 557
.FF.......FF......./Users/gary/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activerecord-5.1.2/lib/active_record/associations/builder/singular_association.rb:17: warning: method redefined; discarding old reload_creator
/Users/gary/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activerecord-5.1.2/lib/active_record/associations/builder/singular_association.rb:17: warning: previous definition of reload_creator was here
/Users/gary/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activerecord-5.1.2/lib/active_record/associations/builder/singular_association.rb:17: warning: method redefined; discarding old reload_updater
/Users/gary/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activerecord-5.1.2/lib/active_record/associations/builder/singular_association.rb:17: warning: previous definition of reload_updater was here
/Users/gary/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activerecord-5.1.2/lib/active_record/associations/builder/singular_association.rb:17: warning: method redefined; discarding old reload_deleter
/Users/gary/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activerecord-5.1.2/lib/active_record/associations/builder/singular_association.rb:17: warning: previous definition of reload_deleter was here
.F...................

Failures:

  1) UsersController when updating a User sets the correct updater
     Failure/Error: patch :update, id: @hera.id, user: { name: 'Different'}

     ArgumentError:
       unknown keywords: id, user
     # ./spec/controllers/users_controller_spec.rb:10:in `block (3 levels) in <top (required)>'

  2) UsersController when handling multiple requests sets the correct updater
     Failure/Error: get :edit, id: @hera.id

     ArgumentError:
       unknown keyword: id
     # ./spec/controllers/users_controller_spec.rb:31:in `block (3 levels) in <top (required)>'

  3) PostsController when handling multiple requests sets the correct updater
     Failure/Error: get :edit, id: @first_post.id

     ArgumentError:
       unknown keyword: id
     # ./spec/controllers/posts_controller_spec.rb:33:in `block (3 levels) in <top (required)>'

  4) PostsController when updating a Post sets the correct updater
     Failure/Error: post :update, id: @first_post.id, post: { title: 'Different' }

     ArgumentError:
       unknown keywords: id, post
     # ./spec/controllers/posts_controller_spec.rb:12:in `block (3 levels) in <top (required)>'

  5) ActiveRecord::Userstamp has a VERSION
     Failure/Error: expect(ActiveRecord::Userstamp::VERSION).to match(/^\d+\.\d+\.\d+$/)

     NameError:
       uninitialized constant ActiveRecord::Userstamp::VERSION
     # ./spec/lib/userstamp_spec.rb:5:in `block (2 levels) in <top (required)>'

Finished in 0.41237 seconds (files took 1.2 seconds to load)
40 examples, 5 failures

Failed examples:

rspec ./spec/controllers/users_controller_spec.rb:8 # UsersController when updating a User sets the correct updater
rspec ./spec/controllers/users_controller_spec.rb:29 # UsersController when handling multiple requests sets the correct updater
rspec ./spec/controllers/posts_controller_spec.rb:31 # PostsController when handling multiple requests sets the correct updater
rspec ./spec/controllers/posts_controller_spec.rb:10 # PostsController when updating a Post sets the correct updater
rspec ./spec/lib/userstamp_spec.rb:4 # ActiveRecord::Userstamp has a VERSION

Randomized with seed 557

Let me know how I can help on this. :)

@lowjoel
Copy link
Owner

lowjoel commented Aug 22, 2017

@blimey85 I've pushed an AR-51 branch that fixes the test cases.

Your specific problem with stamper seems to indicate that the stamper class isn't defined. What is the type of your User equivalent? Is it still User?

@lowjoel
Copy link
Owner

lowjoel commented Aug 22, 2017

@blimey85 I realise this can also happen if model_stamper was not declared on the User model. Did you check that?

@s0nspark
Copy link

I am on rails 5.0.6 and am having this same issue... my stamper is User and I have added model_stamper to the User model class.

The error seems transient - if I refresh a few times it gets past the error and I can access the stamper user through the association.

Any ideas?

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

No branches or pull requests

3 participants