NoBrainerORM / nobrainer

Ruby ORM for RethinkDB
http://nobrainer.io/
Other
386 stars 49 forks source link

Is Nobrainer compatible with Rails engines? #246

Closed zedtux closed 6 years ago

zedtux commented 6 years ago

I'm working on a Rails engine which will have an administration area allowing users to see the data and work with it. I need a document oriented database so as I always wanted to use RethinkDB I'm going for it this time.

So I built my Rails engine which will save a lot of data from the users. I have added the nobrainer gem to the gemspec file and now I'm trying to run the rails g nobrainer:install command but it fails with the following:

/bundle/gems/thor-0.20.0/lib/thor/actions/file_manipulation.rb:263:in `binread': No such file or directory @ rb_sysopen - /application/config/application.rb (Errno::ENOENT)
    from /bundle/gems/thor-0.20.0/lib/thor/actions/file_manipulation.rb:263:in `gsub_file'
    from /bundle/gems/nobrainer-0.33.0/lib/rails/generators/nobrainer/install_generator.rb:31:in `expand_require_rails_all'
    from /bundle/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
    from /bundle/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
    from /bundle/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `block in invoke_all'
    from /bundle/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `each'
    from /bundle/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `map'
    from /bundle/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `invoke_all'
    from /bundle/gems/thor-0.20.0/lib/thor/group.rb:232:in `dispatch'
    from /bundle/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
    from /bundle/gems/railties-5.1.4/lib/rails/generators.rb:269:in `invoke'
    from /bundle/gems/railties-5.1.4/lib/rails/commands/generate/generate_command.rb:24:in `perform'
    from /bundle/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
    from /bundle/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
    from /bundle/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
    from /bundle/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
    from /bundle/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
    from /bundle/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
    from /bundle/gems/railties-5.1.4/lib/rails/engine/commands.rb:7:in `require'
    from /bundle/gems/railties-5.1.4/lib/rails/engine/commands.rb:7:in `<top (required)>'
    from bin/rails:14:in `require'
    from bin/rails:14:in `<main>'

The generator is looking for the config/application.rb file which isn't available at that position in the engine. I have dummy application (living on features/dummy) which could get the modifications.

So did you work on any compatibility with Rails engines or is it something nobody asked before?

nviennot commented 6 years ago

Nobody asked for that feature.

I'm not sure what nobrainer:install should do for a Rails engine. Here's what it does currently: https://github.com/nviennot/nobrainer/blob/master/lib/rails/generators/nobrainer/install_generator.rb#L26-L51

It comments out any ActiveRecord line in most configuration files, and copy the default settings https://github.com/nviennot/nobrainer/blob/master/lib/rails/generators/templates/nobrainer.rb over in the config/initializer directory. For a rails engine, I don't think any of this make sense.

btw, for theadmin area, the systems models can be helpful to introspect the database (http://nobrainer.io/docs/db_management/#accessing_system_tables) I'm seeing that the Users and Permissions table is missing. Let me know if you need it.

zedtux commented 6 years ago

Thank you @nviennot for your quick and nice answer.

Actually I was expecting to only create the Nobrainer initializer but then I was remembering the documentation showing an example of initializer, so copying and pasting it should be enough.

Ideally you could write a line in the doc to tell about it for engines.

BTW there is typo in http://nobrainer.io/docs/persistence/ NoBrainer performs the following stpes: should be NoBrainer performs the following steps: (last word).

And thank you for your link to the system tables 👍