Home
Ruby on Rails
Cheatsheets
Fixtures contain data which can be loaded into your database using migrations. For example, to load data into a table named customers...
ruby script/generate migration load_customers_datacustomers.yml file into your customers table|
customers.yml |
melissa:
name: Melissa
age: 18
david:
name: David
age: 23
|
|
migration.rb |
require 'active_record/fixtures' class LoadCustomerData def self.up down directory = File.join(File.dirname(__FILE__), "data") Fixtures.create_fixtures(directory, "customers") end def self.down Customer.delete_all end end |
A look at the new features and syntax available in migrations on Rails 2.0
More
A brilliant plugin that makes changing your database schema even easier and faster.
More