dynamic_sitemaps icon indicating copy to clipboard operation
dynamic_sitemaps copied to clipboard

Add Scopes

Open GCorbel opened this issue 11 years ago • 1 comments

Hello, I have a bilingual site. It can be useful to add a scope and to something like this sitemap_for Page.scoped, scope: ['en', 'fr'].

What you think?

GCorbel avatar Oct 13 '14 10:10 GCorbel

Just to know, this is the code I created to do what I want :

def sitemap_with_locales_for(records, method)
  sitemap_for records do |model|
    I18n.available_locales.each do |locale|
      I18n.locale = locale
      url send(method, model, locale: locale), last_mod: model.updated_at,
        priority: 1.0
    end
  end
end

prev_locale = I18n.locale
sitemap_with_locales_for(Page.scoped, :page_url)
sitemap_with_locales_for(ProviderProfile.provider_profiles_with_pages, :provider_profile_url)
sitemap_with_locales_for(Artist.all_artists_with_paintings, :artist_url)
I18n.locale = prev_locale

GCorbel avatar Oct 13 '14 11:10 GCorbel