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

Error with method 'neo_id' #42

Open
AlvesJonas opened this issue Jun 29, 2016 · 0 comments
Open

Error with method 'neo_id' #42

AlvesJonas opened this issue Jun 29, 2016 · 0 comments

Comments

@AlvesJonas
Copy link

I have a project in Ruby 2.2.4 with Rails 4.1.2 in which want to implement a new feature to allow users to connect with other users, so I will keep my database in Postgress (using ActiveRecords) with Neoid. I followed all the steps of https://github.com/neoid-gem/neoid documentation, but when I try to save a user has returned the following error:

NoMethodError (undefined method `neo_id 'for # <Hash: 0x0000000a4542a0>)

I have created a new project to analyze if my setup of Neo4j was not the problem, by following this tutorial: https://www.sitepoint.com/using-a-graph-database-with-ruby-part-ii-integration/ and the error did not appear. I tried with another with another class in my project and apparently worked well, which leads me to believe that the problem is something specific in User class. Here the parts involved code:

class User < ActiveRecord::Base 
  devise :database_authenticatable, :registerable, :confirmable,
         :recoverable, :rememberable, :trackable, :validatable, :omniauthable

  include Entity
  include Neoid::Node

  extend FriendlyId

  friendly_id :full_name, use: :slugged

  extend Enumerize
  extend ActiveModel::Naming

  neoidable do |c|
    c.field :slug
  end
  [...]
end

class Connection < ActiveRecord::Base

  include Neoid::Relationship

  belongs_to :user
  belongs_to :connected, class_name: User

  neoidable do |c|
    c.relationship start_node: :user, end_node: :connected, type: :connection
  end
end

class CreateConnections < ActiveRecord::Migration
  def change
    create_table :connections do |t|
      t.integer :user_id
      t.integer :connected_id
      t.timestamps
    end
  end
end

The question is, has anyone ever had a problem like this? Or have some feature in the User class that may be causing this error (like Devise, Enumerize ...)?

Already tried:

  • Reset the Postgress database;
  • Use neo_save on the users, but the error does not allow this action. Like "Inserting records of existing app" on documentation;
  • Check if the user is valid When I try to save;
  • Disabling auto saving to Neo4j;
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

1 participant