annotate db/seeds.rb @ 98:596803cb34fc
luisf
Created a model for the Intitutions;
Created a seed file to initialize the db;
author |
Luis Figueira <luis.figueira@eecs.qmul.ac.uk> |
date |
Thu, 16 Dec 2010 14:55:37 +0000 |
parents |
|
children |
da7cba64948d |
rev |
line source |
luis@98
|
1 # This file should contain all the record creation needed to seed the database with its default values.
|
luis@98
|
2 # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
luis@98
|
3 #
|
luis@98
|
4 # Examples:
|
luis@98
|
5 #
|
luis@98
|
6 # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
|
luis@98
|
7 # Major.create(:name => 'Daley', :city => cities.first)
|
luis@98
|
8
|
luis@98
|
9 Institution.delete_all
|
luis@98
|
10
|
luis@98
|
11 open("db/seed_data/institutions.txt") do |institutions|
|
luis@98
|
12 institutions.read.each_line do |institution|
|
luis@98
|
13 Institution.create(:name => institution.chomp)
|
luis@98
|
14 end
|
luis@98
|
15 end |