5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/observers/gluttonberg/locale_observer.rb', line 5
def after_create(locale)
pages = Page.all
pages.each do |page|
new_localizations = []
new_localizations << page.localizations.create(
:name => page.name,
:locale_id => locale.id
)
unless page.description.sections.empty?
Rails.logger.info("Generating stubbed content for all pages using new localizations")
page.description.sections.each do |name, section|
association = page.send(section[:type].to_s.pluralize)
content = association.find(:first , :conditions => {:section_name => name})
if content && content.class.localized?
new_localizations.each do |localization|
content.localizations.create(:parent => content, :page_localization => localization)
end
end
end
end
end
end
|