错误:模板丢失
缺少模板杂项/站点地图、带有 {:locale=>[:en]、:formats=>[:xml]、:handlers=>[:erb, :builder]} 的应用程序/站点地图。在以下位置搜索:*“/Users/yliu/Google Drive/ruby projects/Blog/lenswish/app/views”*“/usr/local/rvm/gems/ruby-1.9.3-p194/bundler/gems/twitter-bootstrap -rails-4b8a511e6518/app/views" * "/usr/local/rvm/gems/ruby-1.9.3-p194/gems/devise-3.1.0/app/views"
耙路线:
GET /sitemap.xml(.:format) miscellaneous#sitemap {:format=>"xml"}
路线.rb:
get "sitemap.xml", :to => "miscellaneous#sitemap", defaults: { format: "xml" }
控制器:
class MiscellaneousController < ApplicationController
def sitemap
@card_templates = CardTemplate.all
respond_to do |format|
format.xml
end
end
end
模板位置:app/views/miscellaneous/sitemap.xml.builder
模板 sitemap.xml.builder 中的内容:
# Sitemaps 0.9 XML format: http://www.sitemaps.org/protocol.php
xml.instruct!
xml.urlset :xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9' do
xml.url do
xml.loc root_url
xml.changefreq 'daily'
xml.lastmod @card_templates.first.updated_at.iso8601
xml.priority '0.8'
end
end
我已经检查了文件权限问题。还是行不通。请任何人帮忙。提前致谢。