diff --git a/app/models/layout.rb b/app/models/layout.rb index cc1ea534..24425784 100644 --- a/app/models/layout.rb +++ b/app/models/layout.rb @@ -1,7 +1,8 @@ class Layout < CouchFoo::Base property :name, String - property :content, String + property :content, String #remove later + property_i18n :content, String validates_presence_of :name diff --git a/app/models/page.rb b/app/models/page.rb index f7227225..1b4521a0 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -1,13 +1,9 @@ class Page < CouchFoo::Base - property :lang, String property :name, String property :parent_page_id, String - property :content_zh_tw, String - property :content_en, String - property :content_ja, String - # TODO: more language can dynamic added + property_i18n :content, String property :layout_id, String property :layout_name, String diff --git a/app/models/snippet.rb b/app/models/snippet.rb index c21f958f..e2a6f3d9 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -1,8 +1,9 @@ class Snippet < CouchFoo::Base property :name, String - property :content, String - + property :content, String # remove later + property_i18n :content, String + validates_presence_of :name end \ No newline at end of file diff --git a/config/environment.rb b/config/environment.rb index 5e11e952..c6fd1f9b 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -43,4 +43,16 @@ end VALID_LOCALES = ["en", "zh_tw"] require 'couch_foo' -CouchFoo::Base.set_database(:host => "http://localhost:5984", :database => "r4") \ No newline at end of file +CouchFoo::Base.set_database(:host => "http://localhost:5984", :database => "r4") + +class CouchFoo::Base + + def self.property_i18n(property_name, property_type) + VALID_LOCALES.each do |locale| + property "#{property_name.to_s}_#{locale}", property_type + end + end + +end + +