Class: Gluttonberg::LocaleObserver
- Inherits:
-
ActiveRecord::Observer
- Object
- ActiveRecord::Observer
- Gluttonberg::LocaleObserver
- Defined in:
- app/observers/gluttonberg/locale_observer.rb
Overview
Locale Observer makes sures that if new locale is created then create localization for existing pages It also adjusts some variables on locale update
Instance Method Summary collapse
-
#after_create(locale) ⇒ Object
create localization for existing pages.
- #after_update(locale) ⇒ Object
Instance Method Details
#after_create(locale) ⇒ Object
create localization for existing pages
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/observers/gluttonberg/locale_observer.rb', line 10 def after_create(locale) Page.all.each do |page| #create localizations for all pages for new locale new_localizations = create_page_localization(page, locale) # 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 create_page_content(page, new_localizations, name, section) end end end end |
#after_update(locale) ⇒ Object
26 27 28 29 30 |
# File 'app/observers/gluttonberg/locale_observer.rb', line 26 def after_update(locale) existing_localization_ids = [] remove_list = [] new_localizations = [] end |