Add CouchFoo.property_i18n method
This commit is contained in:
parent
c895469d34
commit
28612514e3
|
@ -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,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
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
class Snippet < CouchFoo::Base
|
||||
|
||||
property :name, String
|
||||
property :content, String
|
||||
property :content, String # remove later
|
||||
property_i18n :content, String
|
||||
|
||||
validates_presence_of :name
|
||||
|
||||
|
|
|
@ -44,3 +44,15 @@ end
|
|||
VALID_LOCALES = ["en", "zh_tw"]
|
||||
require 'couch_foo'
|
||||
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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue