Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit d4a1822e59e03dfa81deb71027249b4c7ef43648 1 parent b65076a
Tobias Bielohlawek authored March 08, 2011

Showing 1 changed file with 8 additions and 5 deletions. Show diff stats Hide diff stats

  1. 13  lib/big_sitemap.rb
13  lib/big_sitemap.rb
@@ -322,15 +322,19 @@ def url_for_sitemap(path)
322 322
 end
323 323
 
324 324
 
325  
-
326 325
 class BigSitemapRails < BigSitemap
327 326
 
  327
+  if defined?(Rails) && Rails.version < "3"
  328
+    include ActionController::UrlWriter
  329
+  end
328 330
 
329 331
   def initialize(options={})
  332
+    raise "No Rails Environment loaded" unless defined? Rails
330 333
     require 'action_controller'
331  
-    # I get undefined method `include' for BigSitemapRails ...
332  
-    # I'm forced to include this module before calling BigSitemapRails
333  
-    #include Rails.application.routes.url_helpers if defined? Rails
  334
+
  335
+    if Rails.version >= "3"
  336
+      self.class.send(:include, Rails.application.routes.url_helpers)
  337
+    end
334 338
 
335 339
     DEFAULTS.merge!(:document_root => "#{Rails.root}/public", :url_options => default_url_options)
336 340
     super(options)
@@ -339,7 +343,6 @@ def initialize(options={})
339 343
 end
340 344
 
341 345
 
342  
-
343 346
 class BigSitemapMerb < BigSitemap
344 347
 
345 348
   def initialize(options={})

0 notes on commit d4a1822

Please sign in to comment.
Something went wrong with that request. Please try again.