'add' method isn't working properly #30

Closed
urieljuliatti opened this Issue Feb 9, 2012 · 3 comments

4 participants

@urieljuliatti

It seems that the add method isn't working properly on my application.

After generate the sitemap xml i get some incompatibilities from the generated file compared to my application routes, ex:

It should return:
<url>
<loc>http://www.urieljuliatti.com.br/produto/1-ecailles-de-la-lune</loc>
<lastmod>2011-12-05</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>

Instead of:

<url>
<loc>http://www.urieljuliatti.com.br/1-ecailles-de-la-lune</loc>
<lastmod>2011-12-05</lastmod>
<changefreq>daily</changefreq>
<priority>0.5</priority>
</url>

My routing system returns /produto/1-ecailles-de-la-lune, but the generated sitemap file doesn't include the product controller param. What's going on?

That's my rake task implementation:
namespace :sitemap do
task :generate, [ :needs ] => [ :environment ] do
require 'big_sitemap'
include Rails.application.routes.url_helpers
include I18n
I18n.locale = :ptBR
BigSitemap.generate(:base_url => Store.default.url, :document_root => "#{Rails.root}/public", :document_full => "#{Rails.root}/public") do
Product.all.each do |product|
add show_product_path(product), :change_frequency => 'daily', :priority => 0.5, :last_modified => product.updated_at
end
Brand.all.each do |brand|
add brand_path(brand), :change_frequency => 'daily', :priority => 0.5, :last_modified => brand.updated_at
end
end
end
end

@edzhelyov

The url generation is broken, only the last part of the url is taken into account.
There is a commit in master that attempts to fix this, but will only work on ruby 1.9.1+.

I've submitted a pull request that fix this issue, try it from here: https://github.com/edzhelyov/big_sitemap
until it gets merged into master.

@alexrabarts
Owner

Gem version 1.0.1 has now been released with Evgeni's fix applied. Please upgrade and report back with any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment