Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Scopes #27

Open
GCorbel opened this issue Oct 13, 2014 · 1 comment
Open

Add Scopes #27

GCorbel opened this issue Oct 13, 2014 · 1 comment

Comments

@GCorbel
Copy link

GCorbel commented Oct 13, 2014

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
Copy link
Author

GCorbel commented Oct 13, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant