Sha256: 15c0cfb8460c5e1893d86a80777873471eeb91f0632c6c015ba0aa990668c210
Contents?: true
Size: 1.34 KB
Versions: 15
Compression:
Stored size: 1.34 KB
Contents
module Gluttonberg class LocaleObserver < ActiveRecord::Observer observe Locale def after_create(locale) pages = Page.all pages.each do |page| #create localizations for all pages for new locale new_localizations = [] new_localizations << page.localizations.create( :name => page.name, :locale_id => locale.id ) # create content localizations unless page.description.sections.empty? Rails.logger.info("Generating stubbed content for all pages using new localizations") page.description.sections.each do |name, section| # Create the content association = page.send(section[:type].to_s.pluralize) content = association.find(:first , :conditions => {:section_name => name}) # Create each localization if content && content.class.localized? new_localizations.each do |localization| content.localizations.create(:parent => content, :page_localization => localization) end end end end end end def after_update(locale) existing_localization_ids = [] remove_list = [] new_localizations = [] end end end
Version data entries
15 entries across 15 versions & 1 rubygems