Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

DRYing up YAML fixtures

// Rails Recipes explained how to DRY up the database configuration code. I applied the same idea to user fixtures, which worked while we used MySQL. Once on Postgres, "defaults" started throwing an error. The easiest solution was to make quentin's values the 'defaults'

quentin: &defaults
  id: 1
  login: quentin
  email: quentin@example.com
  site_id: 1
  salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd
  crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test
  created_at: <%= 5.days.ago.to_s :db %>
  activated_at: <%= 5.days.ago.to_s :db %> # only if you're activating new signups
aaron:
  id: 2
  login: aaron
  email: aaron@example.com
  activation_code: aaronscode
  site_id: 1
  <<: *defaults
#etc...

DRY RAILS database.yml config file

From http://blog.bleything.net/articles/2006/06/27/dry-out-your-database-yml:



login: &login
  adapter: mysql
  username: username
  password: password
  host: mysql.example.com

development:
  <<: *login
  database: app_dev

test:
  <<: *login
  database: app_test

production:
  <<: *login
  database: app_prod
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS