neo4jrb / activegraph

An active model wrapper for the Neo4j Graph Database for Ruby.
http://neo4jrb.io
MIT License
1.4k stars 276 forks source link

Session creation error after migration to Ruby 2.3 with rails 4.2.5 #1103

Open pdipietro opened 8 years ago

pdipietro commented 8 years ago

I just upgraded my environment to rails 4.2.5 and Ruby 2.3.0, without changing the code or the DB.

The following line, csn = SocialNetwork.find_by( :iname => sn.downcase ) , running without problems before the upgrade, now returns the following error:

I, [2016-01-14T02:15:56.923728 #39273]  INFO -- : Completed 500 Internal Server Error in 5ms (ActiveRecord: 0.0ms)
F, [2016-01-14T02:15:56.926244 #39273] FATAL -- : 
RuntimeError (No session, please create a session first with Neo4j::Session.open(:server_db) or :embedded_db):
  app/helpers/application_helper.rb:116:in `load_social_network_from_url'
  app/helpers/sessions_helper.rb:307:in `check_social_network'

This is my gemfile:

source 'https://rubygems.org'

ruby '2.3.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails'   #, '4.2.3'
# Use SCSS for stylesheets
gem 'sass-rails'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails'

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder'#, '>= 2.2.3'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', group: :doc

# Use sqlite3 as the database for Active Record
gem 'activemodel'
gem 'sqlite3'

gem 'neo4j', '~> 6.0.1'
#gem 'neo4j', '~> 5.0.15'
#gem 'neo4j', github: 'neo4jrb/neo4j', ref: 'd6783e81ebedb542f188d721a6a4355d8e0071d8'
gem 'neo4jrb_spatial'

gem 'bcrypt'
gem 'faker'
gem 'mini_magick'
#gem 'mini_magick',             '3.8.0'
gem 'fog'
gem 'will_paginate'
#gem 'will_paginate',           '3.0.7'
gem 'bootstrap-will_paginate'
gem 'bootstrap-sass'
gem 'sass_paths'
gem "neo4j-will_paginate_redux"

gem "haml-rails"

gem "pry-rails"

gem 'jquery-turbolinks'
gem 'responders', '~> 2.0'
gem 'bootstrap_form'
gem 'rack-cors', :require => 'rack/cors'
gem 'bootstrap_colorpicker_rails'
gem 'bootstrap-switch-rails'

gem 'remotipart'
gem "inline_svg"
gem 'google-webfonts-rails'

gem 'sprockets-rails', :require => 'sprockets/railtie'
#gem 'sprockets', "< 3.0.0"
#gem 'sprockets-rails'

gem 'url_safe_base64'
gem 'bootstrap-wysihtml5-rails'

gem 'cloudinary'

gem 'geocoder'

gem 'http_accept_language'

gem 'paperclip'

group :development do
#  gem 'sass-rails-source-maps'
  gem 'coffee-rails-source-maps'
end

group :development, :test do
  gem 'web-console',        '~> 2.2'
  gem 'byebug'
end

group :test do
  gem 'minitest-reporters', '1.0.5'
  gem 'mini_backtrace',     '0.1.3'
  gem 'guard-minitest',     '2.3.1'
  gem 'spring'
end

group :production do
  gem 'rails_12factor',     '0.0.2'
  gem 'unicorn',            '4.8.3'
end
subvertallchris commented 8 years ago

Hey Paolo! There was a bug briefly in the gem that caused this. Please upgrade to the last micro release of 6.0.x or move to the most recent 6.1.x release and it will be fixed. I believe it was a bug in Neo4j-core, we released a patch to correct it. I am not on my computer at the moment but if you look at that repo's change log, you will see it in a recent release.

On Wednesday, January 13, 2016, Paolo Di Pietro notifications@github.com wrote:

I just upgraded my environment to rails 4.2.5 and Ruby 2.3.0, without changing the code or the DB.

The following line, csn = SocialNetwork.find_by( :iname => sn.downcase ) , running without problems before the upgrade, now returns the following error:

I, [2016-01-14T02:15:56.923728 #39273] INFO -- : Completed 500 Internal Server Error in 5ms (ActiveRecord: 0.0ms) F, [2016-01-14T02:15:56.926244 #39273] FATAL -- : RuntimeError (No session, please create a session first with Neo4j::Session.open(:server_db) or :embedded_db): app/helpers/application_helper.rb:116:in load_social_network_from_url' app/helpers/sessions_helper.rb:307:incheck_social_network'

This is my gemfile:

source 'https://rubygems.org'

ruby '2.3.0'

Bundle edge Rails instead: gem 'rails', github: 'rails/rails'

gem 'rails' #, '4.2.3'

Use SCSS for stylesheets

gem 'sass-rails'

Use Uglifier as compressor for JavaScript assets

gem 'uglifier'

Use CoffeeScript for .coffee assets and views

gem 'coffee-rails'

Use jquery as the JavaScript library

gem 'jquery-rails'

Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks

gem 'turbolinks'

Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder

gem 'jbuilder'#, '>= 2.2.3'

bundle exec rake doc:rails generates the API under doc/api.

gem 'sdoc', group: :doc

Use sqlite3 as the database for Active Record

gem 'activemodel' gem 'sqlite3'

gem 'neo4j', '~> 6.0.1'

gem 'neo4j', '~> 5.0.15'

gem 'neo4j', github: 'neo4jrb/neo4j', ref: 'd6783e81ebedb542f188d721a6a4355d8e0071d8'

gem 'neo4jrb_spatial'

gem 'bcrypt' gem 'faker' gem 'mini_magick'

gem 'mini_magick', '3.8.0'

gem 'fog' gem 'will_paginate'

gem 'will_paginate', '3.0.7'

gem 'bootstrap-will_paginate' gem 'bootstrap-sass' gem 'sass_paths' gem "neo4j-will_paginate_redux"

gem "haml-rails"

gem "pry-rails"

gem 'jquery-turbolinks' gem 'responders', '~> 2.0' gem 'bootstrap_form' gem 'rack-cors', :require => 'rack/cors' gem 'bootstrap_colorpicker_rails' gem 'bootstrap-switch-rails'

gem 'remotipart' gem "inline_svg" gem 'google-webfonts-rails'

gem 'sprockets-rails', :require => 'sprockets/railtie'

gem 'sprockets', "< 3.0.0"

gem 'sprockets-rails'

gem 'url_safe_base64' gem 'bootstrap-wysihtml5-rails'

gem 'cloudinary'

gem 'geocoder'

gem 'http_accept_language'

gem 'paperclip'

group :development do

gem 'sass-rails-source-maps'

gem 'coffee-rails-source-maps' end

group :development, :test do gem 'web-console', '~> 2.2' gem 'byebug' end

group :test do gem 'minitest-reporters', '1.0.5' gem 'mini_backtrace', '0.1.3' gem 'guard-minitest', '2.3.1' gem 'spring' end

group :production do gem 'rails_12factor', '0.0.2' gem 'unicorn', '4.8.3' end

— Reply to this email directly or view it on GitHub https://github.com/neo4jrb/neo4j/issues/1103.

pdipietro commented 8 years ago

Hmmm, interesting.

Now i saw that there are other changes: for example, the following declaration returns an error, Because Subject is a Class name

class Likes
  include Neo4j::ActiveRel
  include CreatedAtUpdatedAt

  from_class  Subject
  to_class    :any
  type 'likes'

end

but now it wants string or symbols!

F, [2016-01-14T11:33:17.872371 #40354] FATAL -- : 
ArgumentError (from_class option must by String, Symbol, false, nil, or an Array of Symbols/Strings (was Subject(activated: ActiveAttr::Typecasting::Boolean, activated_at: DateTime, activation_digest: String, admin: ActiveAttr::Typecasting::Boolean, created_at: DateTime, email: String, first_name: String, last_name: String, nickname: String, password_digest: Object, remember_digest: String, reset_digest: String, reset_sent_at: DateTime, updated_at: DateTime))):
  app/models/likes.rb:5:in `<class:Likes>'

I have to re-read the docs ;-)

cheerfulstoic commented 8 years ago

Yep, we changed that in 6.1.0 because it was causing problems for people. I updated to docs, but let me know if there's any place I missed!

Thanks

On Jan 14, 2016, at 17:36, Paolo Di Pietro notifications@github.com wrote:

Hmmm, interesting.

Now i saw that there are other changes: for example, the following declaration returns an error, Because Subject is a Class name

class Likes include Neo4j::ActiveRel include CreatedAtUpdatedAt

from_class Subject to_class :any type 'likes'

end but now it wants string or symbols!

F, [2016-01-14T11:33:17.872371 #40354] FATAL -- : ArgumentError (from_class option must by String, Symbol, false, nil, or an Array of Symbols/Strings (was Subject(activated: ActiveAttr::Typecasting::Boolean, activated_at: DateTime, activation_digest: String, admin: ActiveAttr::Typecasting::Boolean, created_at: DateTime, email: String, first_name: String, last_name: String, nickname: String, password_digest: Object, remember_digest: String, reset_digest: String, reset_sent_at: DateTime, updated_at: DateTime))): app/models/likes.rb:5:in `class:Likes' I have to re-read the docs ;-)

— Reply to this email directly or view it on GitHub.

pdipietro commented 8 years ago

Well, I read the docs and changed all the rels using Symbols. But now, the original problem is still there: csn = SocialNetwork.find_by( :iname => sn.downcase )

I, [2016-01-14T12:08:17.698539 #40619]  INFO -- : Completed 500 Internal Server Error in 4ms (ActiveRecord: 0.0ms)
F, [2016-01-14T12:08:17.700002 #40619] FATAL -- : 
RuntimeError (No session, please create a session first with Neo4j::Session.open(:server_db) or :embedded_db):
  app/helpers/application_helper.rb:116:in `load_social_network_from_url'
  app/helpers/sessions_helper.rb:307:in `check_social_network'

and these are my gems:

joinple@JPL-dev-03:~/joinple$ gem list neo

*** LOCAL GEMS ***

neo4j (6.1.1, 6.0.5)
neo4j-core (6.1.1, 6.0.6)
neo4j-rake_tasks (0.4.0)
neo4j-will_paginate_redux (0.3.4)
neo4jrb_spatial (1.1.0)
subvertallchris commented 8 years ago

Hey Paolo, sorry for not getting back to you on this. Did you find a resolution?

pdipietro commented 8 years ago

Yes Chris, just while writing this email ;-)

I'm doing a really bored job: reinstalling a linux machine from scratch, with the latest versions of ruby and rails.

Then I dowload the ebook copy of your neo4jrb.epub and spent last full night to read it with attention. (btw, I founded a couple of typos and opened an issue to verify them !)

The original problem has been solved replacing tabs with spaces, added by the editor while I added the production portion of the neo4j.yml file.

As a suggestion, you can remember people to not use tabs in .yml files, putting a no-tabs icon on the manual near each .yml . I know this could seems OT, but it can surely help.

NEW with ruby 2.3.0 and neo4j 6.1.1 the following error arises while starting neo4j:

require 'uri'

module Neo4j
  module Server
    Neo4j::Session.register_db(:server_db) do |endpoint_url, url_opts|
      Neo4j::Server::CypherSession.open(endpoint_url, url_opts)
    end

    class CypherSession < Neo4j::Session        **<-- incoprrect inheritance**
      include Resource

There are also incompatibility with the following gems:

 # gem 'neo4jrb_spatial'
 group :development do
   # gem 'sass-rails-source-maps'
 end

and there is an annoying problem with web-console, already signaled but still not solved. Btw, iweb-console requires at least ruby.2.2.2, and this was the initial reason we start the upgrate.

group :development do
  gem 'web-console', '~> 2.0'
end

I found the manual unvaluable, because is the first (real) attempt to have an ordered and detailed explanation of all the things related with the gem.

Some explanation about the autosaving of relationsips with not yet saved nodes are very important for us.

So, I'm now rechecking, a class after the other, the entire project with these suggestions in my head, and I'll let you know how it proceeds, and if I'll find new typos on the manual..

cheerfulstoic commented 8 years ago

I'm glad you found the epub useful! ;) I've always used the RTD website so far.

If you find any typos issues are good, though pull requests are better! All of the documentation is in the neo4j gem repository under the docs folder:

https://github.com/neo4jrb/neo4j/tree/master/docs

It uses restructuredtext / sphinx which is a python thing, but it seems to be the best way of making documentation on readthedocs. Each page in the manual on readthedocs.org should have a link to the corresponding GitHub page so it should be easy to fix typos.

I'm not sure I understand the other issue with 2.3.0. Could you open a new issue with the details of the error?

Thanks!