使用方法如下:
1
| caches_page :index,:sitemap
|
ApplicationController:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| def sitemap @page = { 'title' => @siteconfigs.companyname, 'keywords' => @siteconfigs.keywords, 'description' => @siteconfigs.description } @articles = Article.all @products = Product.all @faqs = Faq.all @singlepage = Singlepage.all @services = Service.all @downloads = Download.all
respond_to do |format| format.html { render 'home/sitemap',layout: false} format.xml { render 'home/sitemap.xml',layout: false } end end
|
创建两个视图文件 sitemap.html 和 sitemap.xml