Rails站点地图生成器,未定义的方法post_path?

时间:2011-02-01 00:21:20

标签: ruby-on-rails-3 path rubygems sitemap

我正在使用以下gem:

https://github.com/kjvarga/sitemap_generator

我有一个帖子模型,并且在应用程序的其他部分使用了post_path(post),因为它基于Enki。

但是在站点地图文件中:

Post.all.each do |post|
    sitemap.add post_path(post), :lastmod => post.updated_at
  end

这会在运行rake task rake sitemap时返回错误:refresh:

rake aborted!
undefined method `post_path' for #<SitemapGenerator::Interpreter:0x279efd0>

Post.all.each do |post|
  sitemap.add posts_path(post), :lastmod => post.updated_at
end

不返回任何错误。任何人都可以对此有所了解,还是我需要提供更多代码?

1 个答案:

答案 0 :(得分:0)

我觉得这个有点愚蠢,这只是因为post_path是一个帮手并且无法访问,所以我只需要将它直接移到方法中。