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

About this user

Daniel Haran

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 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'

   1  
   2  quentin: &defaults
   3    id: 1
   4    login: quentin
   5    email: quentin@example.com
   6    site_id: 1
   7    salt: 7e3041ebc2fc05a40c60028e2c4901a81035d3cd
   8    crypted_password: 00742970dc9e6319f8019fd54864d3ea740f04b1 # test
   9    created_at: <%= 5.days.ago.to_s :db %>
  10    activated_at: <%= 5.days.ago.to_s :db %> # only if you're activating new signups
  11  aaron:
  12    id: 2
  13    login: aaron
  14    email: aaron@example.com
  15    activation_code: aaronscode
  16    site_id: 1
  17    <<: *defaults
  18  #etc...
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS