howto use neojrb together with active record

43 views
Skip to first unread message

fap2...@gmail.com

unread,
Oct 22, 2014, 5:25:55 PM10/22/14
to neo...@googlegroups.com
So I installed neoj4rb with the following approach. I can create neo4j classes with scaffold. So here come my rookie question:

what are my approach to create active records objects with scaffold? So is there some way I can differentiate between creating activerecords and neo4j classes with scaffolding?

Yes, I'm still a novice. So bare with me.

  1. I manually inserted "gem 'neo4j', '3.0.0.rc.3'" into my gemfile and ran the bundle command.

  2. I manually inserted  "require 'neo4j/tasks/neo4j_server'" into the RakeFile, that is already made when I created the application:

    require File.expand_path('../config/application', __FILE__)
    require 'neo4j/tasks/neo4j_server'

    Rails.application.load_tasks

  3. Manually added into the application.rb the following lines in bold:

    require 'neo4j/railtie'

    module GraphNeo4j
     
    class Application < Rails::Application

       
    config.generators do |g|
          g
    .orm             :neo4j
       
    end
       
       
    config.neo4j.session_type = :server_db
        config
    .neo4j.session_path = 'http://localhost:7474'
     
    end
    end

  4. I used 'rake neo4j:install[enterprise-2.1.5]' and it worked fine by installing the neo4j directory.

  5. Created a new comment class. Started up the application

  6. I started the neo4j server. Created a new Commend and saw it in the web server browser. It seems to work.


Chris Grigg

unread,
Oct 22, 2014, 5:42:35 PM10/22/14
to neo...@googlegroups.com
Awesome! Remove the ".rc.3" part from the gemfile. You just want "gem 'neo4j'". Do "bundle update neo4j" when you're done.

I'm not so sure how you can do scaffolds for ActiveRecord once Neo4j is setup. I try not to use scaffolds. ;-) You can create Neo4j models so easily, I don't really find scaffolds super helpful. They are helpful for ActiveRecord, since writing migrations is a pain in the ass.
--
You received this message because you are subscribed to the Google Groups "neo4jrb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4jrb+u...@googlegroups.com.
To post to this group, send email to neo...@googlegroups.com.
Visit this group at http://groups.google.com/group/neo4jrb.
For more options, visit https://groups.google.com/d/optout.

fap2...@gmail.com

unread,
Oct 22, 2014, 6:10:40 PM10/22/14
to neo...@googlegroups.com
Thx. I just use scaffold in the begining of my application. I can see that it is invoking neo4j, so maybe I can change that someplace to active record?

rails g scaffold comment body                                                            
      invoke  neo4j
      create    app
/models/comment.rb
      invoke    rspec
      create      spec
/models/comment_spec.rb
      invoke  resource_route
       route    resources
:comments
      invoke  scaffold_controller
      create    app
/controllers/comments_controller.rb
      invoke    erb



Message has been deleted

Chris Grigg

unread,
Oct 22, 2014, 6:13:33 PM10/22/14
to neo...@googlegroups.com
Gotta tell us what that error is! ;-)


On Wednesday, October 22, 2014, <fap2...@gmail.com> wrote:
If I remove ".rc.3" I get an error.


fap2...@gmail.com

unread,
Oct 22, 2014, 6:15:17 PM10/22/14
to neo...@googlegroups.com
If I remove ".rc.3" I get an error.

Error:[rake --tasks] rake aborted!
LoadError: cannot load such file -- neo4j/tasks/neo4j_server
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `block in require'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `require'
/home/james/Desktop/dev/Afslutningsprojekt/graph-neo4j/Rakefile:5:in `<top (required)>'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `block in load'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/rake-10.3.2/lib/rake/rake_module.rb:28:in `load_rakefile'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/rake-10.3.2/lib/rake/application.rb:687:in `raw_load_rakefile'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/rake-10.3.2/lib/rake/application.rb:94:in `block in load_rakefile'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/rake-10.3.2/lib/rake/application.rb:93:in `load_rakefile'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/rake-10.3.2/lib/rake/application.rb:77:in `block in run'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/home/james/Desktop/dev/Afslutningsprojekt/graph-neo4j/bin/rake:8:in `<top (required)>'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `block in load'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'
/home/james/.rvm/gems/ruby-2.1.3@rails4.1_graph_neo4j/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load'
/home/james/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/home/james/.rvm/rubies/ruby-2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
-e:1:in `<main>'

Chris Grigg

unread,
Oct 22, 2014, 6:16:21 PM10/22/14
to neo...@googlegroups.com
There's a github issue about it, it's still open. I'm on my phone so I can't link you but check for it, it's recent.


On Wednesday, October 22, 2014, <fap2...@gmail.com> wrote:
--
Message has been deleted

fap2...@gmail.com

unread,
Oct 22, 2014, 6:22:29 PM10/22/14
to neo...@googlegroups.com
Ok, thx.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages