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

adding railtie #26

Open
eltupe opened this issue Jul 14, 2016 · 7 comments
Open

adding railtie #26

eltupe opened this issue Jul 14, 2016 · 7 comments

Comments

@eltupe
Copy link

eltupe commented Jul 14, 2016

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.

@cheerfulstoic
Copy link
Contributor

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

@eltupe
Copy link
Author

eltupe commented Jul 15, 2016

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

@cheerfulstoic
Copy link
Contributor

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

@Joshfindit
Copy link

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)

@eltupe
Copy link
Author

eltupe commented Jul 17, 2016

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.

@cheerfulstoic
Copy link
Contributor

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

@cheerfulstoic
Copy link
Contributor

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.

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