[noosfero/noosfero][master] 3 commits: Add seed file for Noosfero with support to plugins custom seed file.

Rodrigo Souto gitlab at gitlab.com
Wed May 13 18:25:20 BRT 2015


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
b985a36e by Gabriela Navarro at 2015-05-13T18:22:28Z
Add seed file for Noosfero with support to plugins custom seed file.

Signed-off-by: Arthur Del Esposte <arthurmde at gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703 at gmail.com>

- - - - -
35872e74 by Rodrigo Souto at 2015-05-13T18:22:28Z
seeds: ensure RAILS_ENV is defined

- - - - -
0096a365 by Rodrigo Souto at 2015-05-13T18:22:28Z
seeds: load plugin seeds instead of opening a new runner for each one

- - - - -


2 changed files:

- + db/seeds.rb
- + plugins/foo/db/seeds.rb


Changes:

=====================================
db/seeds.rb
=====================================
--- /dev/null
+++ b/db/seeds.rb
@@ -0,0 +1,14 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+#
+# Examples:
+#
+#   cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
+#   Mayor.create(name: 'Emanuel', city: cities.first)
+
+ENV['RAILS_ENV'] ||= 'development'
+
+# This is for plugins that wants to use seeds.rb
+# Check for example on the Foo plugin
+plugin_seed_dirs = Dir.glob(Rails.root.join('{baseplugins,config/plugins}', '*', 'db', 'seeds.rb'))
+plugin_seed_dirs.each { |path| load path }


=====================================
plugins/foo/db/seeds.rb
=====================================
--- /dev/null
+++ b/plugins/foo/db/seeds.rb
@@ -0,0 +1,9 @@
+# This file should contain all the record creation needed to seed the database with its default values.
+# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
+#
+# Examples:
+#
+#   cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
+#   Mayor.create(name: 'Emanuel', city: cities.first)
+
+FooPlugin::Bar.create()



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/3e72f54e3e3e41e139faf39914ad141309a23f13...0096a3650a041d81869a1b3c682ffc647111414c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150513/3a2e4d5b/attachment.html>


More information about the Noosfero-dev mailing list