4

I have stated working on neo4j with rails using the gem 'neo4j', I want to seed some data in neo4j database. But whenever I am trying to do rake db:seed, it says

rake aborted!
Don't know how to build task 'db:seed'

I have checked all the rake tasks using rake -T, and there is no rake db:seed.

Does any one have any idea?

Christophe Willemsen
  • 19,399
  • 2
  • 29
  • 36
Sabyasachi Ghosh
  • 2,765
  • 22
  • 33

4 Answers4

2

The Neo4j gem doesn't have a seed command. The command you're trying to use is provided by ActiveRecord. We'd love to add this functionality in, though, and if you'd like to help, we'd gladly accept a PR and/or contribute to the process. For now, open up an issue at https://github.com/neo4jrb/neo4j/issues and we can add it to the roadmap.

subvertallchris
  • 5,282
  • 2
  • 25
  • 43
1

Finally got the solutions.

Create a file seed.rake under lib/tasks and put the code

namespace :db do
  desc 'Load the seed data from db/seeds.rb'
  task :seed => :environment do
    seed_file = File.join(Rails.root, 'db', 'seeds.rb')
    load(seed_file) if File.exist?(seed_file)
  end
end
Sabyasachi Ghosh
  • 2,765
  • 22
  • 33
0

Check apps root directory, is there a Rakefile?
Make a file with name "Rakefile" and enter these line

"#!/usr/bin/env rake
require File.expand_path('../config/application', FILE)
APP_NAME::Application.load_tasks

Ashutosh Tiwari
  • 984
  • 6
  • 16
0

As others mentioned before, rails db:seed is a built-in feature backed by ActiveRecord. Assuming you are using neo4jrb without ActiveRecord, you won't be able to use this command to seed database any more.

However, you can use seedbank gem to recover this ability.

It does not depend on ActiveRecord like seed_fu and other seeding gems do. So it will work just fine with neo4jrb.

The process is rather simple.

  1. put seedbank in your Gemfile and bundle install.
  2. create directory db/seeds/
  3. create a seeds file under the db/seeds/ directory

for example

#db/seeds/show.seeds.rb

Show.create(name: "Better Call Saul", producer: "Vince Gilligan")
  1. run rake db:seed:show
Lil E
  • 388
  • 5
  • 23