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 after adding 'mongoid_includes' to Gemfile #9

Closed
mityakoval opened this issue Dec 16, 2016 · 10 comments
Closed

Comments

@mityakoval
Copy link

mityakoval commented Dec 16, 2016

Hello,

I'm getting NoMethodError: undefined method 'first' for false:FalseClass every time I query for any document. Once I remove this gem from the Gemfile everything works.

The whole stack:

NoMethodError: undefined method 'first' for false:FalseClass
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/mongoid-6.0.2/lib/mongoid/contextual/mongo.rb:271:in 'find_first'
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/mongoid-6.0.2/lib/mongoid/contextual.rb:20:in 'find_first'
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/mongoid-6.0.2/lib/mongoid/findable.rb:114:in 'find_by'
  from (irb):3
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/railties-5.0.0.1/lib/rails/commands/console.rb:65:in 'start'
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/railties-5.0.0.1/lib/rails/commands/console_helper.rb:9:in 'start'
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:78:in 'console'
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in 'run_command!'
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in '<top (required)>'
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in 'require'
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in 'block in require'
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in 'load_dependency'
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in 'require'
  from /Users/mityakoval/RubymineProjects/vaktdagboka/bin/rails:9:in '<top (required)>'
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in 'load'
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in 'block in load'
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in 'load_dependency'
  from /Users/mityakoval/.rvm/gems/ruby-2.3.0@vaktboka/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in 'load'
  from /Users/mityakoval/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in 'require'
  from /Users/mityakoval/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in 'require'
@ElMassimo
Copy link
Owner

@mityakoval Haven't tested the gem with mongoid 6. If you make a PR to add mongoid 6 to the test matrix I can take a look at the failing tests 😃

@mityakoval
Copy link
Author

Ah, okay. I just saw #3 as successfully closed and assumed it already supports mongoid 6. 😃

@ElMassimo
Copy link
Owner

Completely forgot about that PR 😅

I ran tests with 6.0.0, 6.0.1, and 6.0.2. Everything seems to be working correctly in 6.0.0, but from 6.0.1 going forward the same error you posted is happening in some of the scenarios.

I'm not able to take a look at this at the moment, but will happily accept any patch for what seems to be breaking changes in 6.0.1 😃

@ElMassimo
Copy link
Owner

Very likely that it's related to mongodb/mongoid#4326, since in order to get the job done we need to modify some of Mongoid's internals, since it's not designed with extensibility in mind.

@ElMassimo
Copy link
Owner

@ElMassimo
Copy link
Owner

@mityakoval v2.0.0 is now available, thanks again for the bug report!

bhernez added a commit to bhernez/mongoid_includes that referenced this issue Mar 12, 2017
@mrpoundsign
Copy link

@ElMassimo We're also experiencing this with mongoid 5.2.0/mongoid_includes 1.1.3. Any chance of a backport to the 1.1 series?

@ElMassimo
Copy link
Owner

Happy to release a new version, but don't have time to check it until next week.

In the meantime, could you try forking master and changing the gemspec to downgrade the mongoid version (down to 5) and see if you still experience the error?

@mrpoundsign
Copy link

@ElMassimo The issue still exists with mongoid 5.1.6 and mongoid_includes 1.1.3. We cannot currently go back to mongoid 5.0

@ElMassimo
Copy link
Owner

I meant to downgrade the gemspec requirement of this gem in your own fork.

If you don't want to fork this repo, you could try using this in your Gemfile:

gem 'mongoid_includes', git: '[email protected]:ElMassimo/mongoid_includes.git', ref: '05c8d0d409cdc17ca47e8e5cfa04546be47d91f9'

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

3 participants