Describe how to setup sitemap generation with default_url_options
Idea from: http://stackoverflow.com/questions/16720514/how-to-use-url-helpers-in-lib-modules-and-set-host-for-multiple-environments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lib/routing.rb | |
# SO: http://stackoverflow.com/questions/16720514/how-to-use-url-helpers-in-lib-modules-and-set-host-for-multiple-environments | |
module Routing | |
extend ActiveSupport::Concern | |
include Rails.application.routes.url_helpers | |
included do | |
def default_url_options | |
{ :locale => I18n.locale } | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/sitemap.rb | |
require Rails.root.join('lib/routing.rb') | |
### Logic of generating the sitemap | |
SitemapGenerator::Interpreter.send :include, Routing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment