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

Mongoid support #32

Open
Startouf opened this issue Apr 17, 2016 · 3 comments
Open

Mongoid support #32

Startouf opened this issue Apr 17, 2016 · 3 comments

Comments

@Startouf
Copy link
Contributor

Startouf commented Apr 17, 2016

I see no mention of Mongoid anywhere. Is it possible to work with Mongoid at all ? (Even if the database logging doesn't work yet ?)

EDIT -

The current version will cause a wonderful exception (haha sorry about that) when started with a Mongoid-backed DB with default configuration. Adding...

config.exception_handler = {
    db: false
  }

...doesn't seem to help.

Here's the top of my stack trace

[Rails root]/app/models/exception_handler/error.rb:2:in `<module:ExceptionHandler>': uninitialized constant ExceptionHandler::ActiveRecord (NameError)
        from [Rails root]/app/models/exception_handler/error.rb:1:in `<top (required)>'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-5.0.0.beta3/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-5.0.0.beta3/lib/active_support/concurrency/share_lock.rb:117:in `exclusive'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-5.0.0.beta3/lib/active_support/dependencies/interlock.rb:11:in `loading'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.0.beta3/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.0.beta3/lib/rails/engine.rb:475:in `each'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.0.beta3/lib/rails/engine.rb:475:in `block in eager_load!'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.0.beta3/lib/rails/engine.rb:473:in `each'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.0.beta3/lib/rails/engine.rb:473:in `eager_load!'
        from [Rails root]/config.ru:6:in `block in <main>'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-2.0.0.alpha/lib/rack/builder.rb:55:in `instance_eval'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-2.0.0.alpha/lib/rack/builder.rb:55:in `initialize'
        from [Rails root]/config.ru:in `new'
        from [Rails root]/config.ru:in `<main>'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-2.0.0.alpha/lib/rack/builder.rb:49:in `eval'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-2.0.0.alpha/lib/rack/builder.rb:49:in `new_from_string'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-2.0.0.alpha/lib/rack/builder.rb:40:in `parse_file'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-2.0.0.alpha/lib/rack/server.rb:318:in `build_app_and_options_from_config'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-2.0.0.alpha/lib/rack/server.rb:218:in `app'
        from C:/Dev/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.0.beta3/lib/rails/commands/server.rb:58:in `app'
@Startouf
Copy link
Contributor Author

Startouf commented Apr 17, 2016

Sorry, I didn't even notice I ran this after generating the files for my app. Removing the ActiveRecord inheritance and adding include Mongoid::Document in the generated model fixed it, and it is probably gonna work with Mongoid.

So the only point that needs to be revisited, is not to generate ActiveRecord model when running the generator script on Mongoid backed Rails.

@richpeck
Copy link
Owner

richpeck commented May 3, 2017

Hey thank you for the PR - let me check through it will be a few minutes

@fatihtas
Copy link

0.8.0.0 doesn't work with mongoid, I am triying almost half day,
I added
include Mongoid::Document
include Mongoid::Timestamps

and tried to implement @Startouf s commits on my model file as well..
can you please check it @richpeck

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