Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add tolk_migration generator

  • Loading branch information...
commit a586d207b79810aafc06117faf740891ebcdb627 1 parent 4bafade
@lifo lifo authored
View
5 README
@@ -13,7 +13,10 @@ To setup :
# environment.rb
Tolk::Locale.primary_locale_name = 'en'
- 2) Generate a new migration and copy relevant parts of tolk/db/schema.rb to self.up() and migrate
+ 2) Generate tolk migration and migrate your database :
+
+ $ script/generate tolk_migration
+ $ rake db:migrate
* Usage
View
29 generators/tolk_migration/templates/migrate/create_tolk_tables.rb
@@ -0,0 +1,29 @@
+class CreateTolkTables < ActiveRecord::Migration
+ def self.up
+ create_table :locales do |t|
+ t.string :name
+ t.datetime :created_at
+ t.datetime :updated_at
+ end
+
+ create_table :phrases do |t|
+ t.text :key
+ t.datetime :created_at
+ t.datetime :updated_at
+ end
+
+ create_table :translations do |t|
+ t.integer :phrase_id
+ t.integer :locale_id
+ t.text :text
+ t.datetime :created_at
+ t.datetime :updated_at
+ end
+ end
+
+ def self.down
+ drop_table :translations
+ drop_table :phrases
+ drop_table :locales
+ end
+end
View
7 generators/tolk_migration/tolk_migration_generator.rb
@@ -0,0 +1,7 @@
+class TolkMigrationGenerator < Rails::Generator::Base
+ def manifest
+ record do |m|
+ m.migration_template "migrate/create_tolk_tables.rb", "db/migrate", :migration_file_name => "create_tolk_tables"
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.