Permalink
Browse files

BigSitemapRails now works for both 2.x and 3.x version

  • Loading branch information...
1 parent b65076a commit d4a1822e59e03dfa81deb71027249b4c7ef43648 Tobias Bielohlawek committed Mar 8, 2011
Showing with 8 additions and 5 deletions.
  1. +8 −5 lib/big_sitemap.rb
View
@@ -322,15 +322,19 @@ def url_for_sitemap(path)
end
-
class BigSitemapRails < BigSitemap
+ if defined?(Rails) && Rails.version < "3"
+ include ActionController::UrlWriter
+ end
def initialize(options={})
+ raise "No Rails Environment loaded" unless defined? Rails
require 'action_controller'
- # I get undefined method `include' for BigSitemapRails ...
- # I'm forced to include this module before calling BigSitemapRails
- #include Rails.application.routes.url_helpers if defined? Rails
+
+ if Rails.version >= "3"
+ self.class.send(:include, Rails.application.routes.url_helpers)
+ end
DEFAULTS.merge!(:document_root => "#{Rails.root}/public", :url_options => default_url_options)
super(options)
@@ -339,7 +343,6 @@ def initialize(options={})
end
-
class BigSitemapMerb < BigSitemap
def initialize(options={})

0 comments on commit d4a1822

Please sign in to comment.