devise-activegraph icon indicating copy to clipboard operation
devise-activegraph copied to clipboard

adding railtie

Open eltupe opened this issue 9 years ago • 7 comments

Hi,

Following the instructions gave me the error "No session, please create a session first with Neo4j::Session.open(:server_db) or :embedded_db)" upon account creation. Had to add: require 'neo4j/railtie' to /config/application.rb

you might want to include this in the instructions.

eltupe avatar Jul 14 '16 09:07 eltupe

Thanks for opening an issue!

We actually have this as an item under the docs for "Adding the gem to an existing project" in the "Ruby on Rails" section:

http://neo4jrb.readthedocs.io/en/7.0.x/Setup.html#adding-the-gem-to-an-existing-project

That section is a big long, though. I'd definitely like to make these things as findable as possible. What was your experience like?

Thanks again

cheerfulstoic avatar Jul 14 '16 21:07 cheerfulstoic

I'm actually talking about the example app on: https://github.com/neo4jrb/devise-neo4j

If I follow the instructions it works fine except for the error described above. I would suggest to add it to the instructions for the example app (not the neo4j docs). In my opinion one should be able to follow the instructions for the example app without having to check the docs. I would suggest adding it here:

Add to your config/routes.rb:

devise_for :users root :to => "secrets#show"

Add to your config/application.rb:

require 'neo4j/railtie'

btw.: i'm actually creating a completely new app here, so it has nothing to do with "Adding the gem to an existing project".

greetings

eltupe avatar Jul 15 '16 15:07 eltupe

Ah, perhaps you missed the rails new command for creating a new Rails app?

http://neo4jrb.readthedocs.io/en/7.0.x/Setup.html#generating-a-new-app

That should automatically set up the application.rb for you. But again, it might not be as easy to find. We should definitely look to improve that

cheerfulstoic avatar Jul 15 '16 21:07 cheerfulstoic

Came across this issue because I also had the error.

Followed the example code on the README:

Example App

You can see a very simple app that demonstrates Neo4j and devise here:

gem install rails
rails new myapp -m http://neo4jrb.io/neo4j/rails.rb -O
cd myapp

# Add the gem to your Gemfile, then run bundle:
gem 'devise-neo4j'
bundle

rails generate devise:install --orm=neo4j

# Install the database unless you already have a Neo4j database, or use JRuby Embedded Neo4j db
rake neo4j:install[community-2.2.2] # check which one is the latest
rake neo4j:start

rails g neo4j:devise User

# Add to your config/routes.rb:
devise_for :users
root :to => "secrets#show"

# Generate a controller for the protected content
rails g controller secrets show

# In app/controllers/secrets_controller.rb add:
before_action :authenticate_user!

# In app/views/secrets/show.html.erb add:
<p>Shhhh... this page is only visible to logged-in users!</p>
<%= link_to "Log out", destroy_user_session_path, method: :delete  %>

# Start the application and visit http://localhost:3000/users/sign_up
rails s

As above, when submitting the user registration; No session, please create a session first with Neo4j::Session.open(:server_db) or :embedded_db)

Joshfindit avatar Jul 16 '16 18:07 Joshfindit

Exactly, for some reason the rails new command (which, of course, I have been using @brian) does not insert the the require 'neo4j/railtie' into the application.rb file.

eltupe avatar Jul 17 '16 09:07 eltupe

Ah, good to know! I wonder if maybe it broke with Rails 5. I'll have a look soon!

cheerfulstoic avatar Jul 17 '16 15:07 cheerfulstoic

Ok, I think I've fixed it now. Try generating an app again?

Thanks for reporting this!

I also noticed that you're using rails.rb, though all the documentation that I know of has been using neo4j.rb. rails.rb was very out of date, so I symlinked it to neo4j.rb.

cheerfulstoic avatar Jul 19 '16 08:07 cheerfulstoic