Add CouchFoo.property_i18n method

This commit is contained in:
Wen-Tien Chang committed 2009-06-26 21:16:37 +08:00
1 parent c895469d34
commit 28612514e3
4 files changed
+19 -9

No files matched your search

+2 -1
View File
@@ -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
+1 -5
View File
@@ -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
+3 -2
View File
@@ -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
+13 -1
View File
@@ -43,4 +43,16 @@ end
VALID_LOCALES = ["en", "zh_tw"]
require 'couch_foo'
CouchFoo::Base.set_database(:host => "http://localhost:5984", :database => "r4")
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