Edition of page part for multiple languages.

This commit is contained in:
chris2tof committed 2011-05-27 11:27:54 +08:00
1 parent 0969f6b6cc
commit 2522cde2f5
13 files changed
+70 -18

No files matched your search

+17
View File
@@ -6,7 +6,24 @@ class PagePart
field :name
field :content
field :kind
field :i18n_variable_id, :type => BSON::ObjectId
belongs_to :page
# Get the i18n_variable
def i18n_variable
@i18n_variable ||= I18nVariable.find(self.i18n_variable_id) rescue nil
end
# Update or create the i18n_variable record
def i18n_variable=(attr)
if self.i18n_variable_id
self.i18n_variable.update_attributes(attr)
else
var = I18nVariable.new(attr.merge({:key => self.key, :document_class => self.class, :parent_id => self.page.i18n_variable_id}))
var.save
self.i18n_variable_id = var.id
end
end
end