Skip to content

Instantly share code, notes, and snippets.

@parndt
Created February 7, 2012 20:43
Show Gist options
  • Save parndt/1761816 to your computer and use it in GitHub Desktop.
Save parndt/1761816 to your computer and use it in GitHub Desktop.
Seeding in a few locales
page_position = -1
I18n.locale = :en
tuning_page = Page.create(:title => "Tuning", :deletable => true, :position => (page_position += 1))
I18n.locale = :fr
tuning_page.title = 'French Tuning'
tuning_page.save
I18n.locale = :es
tuning_page.title = 'Spanish Tuning'
tuning_page.save
# You should now have one page with 3 locales.
I18n.locale = :en
another_page = Page.create(:title => 'Another', :deletable => true, :position => (page_position += 1))
I18n.locale = :fr
another_page.title = 'Another French'
another_page.save
I18n.locale = :es
another_page.title = 'Another Spanish'
another_page.save
# You should now have 2 pages with 3 locales each.
# hope this helps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment