Commit b985a36e527ad494dcc69d1f6210e8c0334fcc2a

Authored by Gabriela Navarro
Committed by Rodrigo Souto
1 parent 3e72f54e

Add seed file for Noosfero with support to plugins custom seed file.

Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing 2 changed files with 24 additions and 0 deletions   Show diff stats
db/seeds.rb 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +# This file should contain all the record creation needed to seed the database with its default values.
  2 +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
  3 +#
  4 +# Examples:
  5 +#
  6 +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
  7 +# Mayor.create(name: 'Emanuel', city: cities.first)
  8 +
  9 +
  10 +# This is for plugins that wants to use seeds.rb
  11 +# Check for example on the Foo plugin
  12 +plugin_seed_dirs = Dir.glob(Rails.root.join('{baseplugins,config/plugins}', '*', 'db', 'seeds.rb'))
  13 +plugin_seed_dirs.each do |path|
  14 + system "rails runner #{path}"
  15 +end
... ...
plugins/foo/db/seeds.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +# This file should contain all the record creation needed to seed the database with its default values.
  2 +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
  3 +#
  4 +# Examples:
  5 +#
  6 +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
  7 +# Mayor.create(name: 'Emanuel', city: cities.first)
  8 +
  9 +FooPlugin::Bar.create()
... ...