2013-11-27 104 views
0

錯誤: 模板丟失導軌xml.builder缺少模板錯誤

缺少模板雜/地圖,應用/網站地圖與{:區域設置=> [:EN]:格式=> [:XML],:處理程序=> [: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 /應用/視圖」 * 「/usr/local/rvm/gems/ruby-1.9.3-p194/gems/devise-3.1.0/app/views」

耙路線:

GET  /sitemap.xml(.:format)     miscellaneous#sitemap {:format=>"xml"} 

routes.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 

模板位置: 應用程序/視圖/雜項/ 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 

我已籤文件的權限問題。還是行不通。任何人都請幫忙。提前致謝。

回答

0

這看起來我錯了:

GET  /sitemap.xml(.:format)     miscellaneous#sitemap {:format=>"xml"} 

它不應該是這樣嗎?

GET  /sitemap(.:format)     miscellaneous#sitemap {:format=>"xml"} 

我想你的路線更改爲:

get "sitemap", :to => "miscellaneous#sitemap" 

控制器代碼看起來應該差不多

class MiscellaneousController < ApplicationController 
    def sitemap 
    @card_templates = CardTemplate.all 
    respond_to do |format| 
     format.xml 
    end 
    end 
end 
+0

不適合我。仍然有同樣的錯誤。 –

+0

做了一些更改。讓我知道這是否有幫助。 –

+0

仍然收到相同的錯誤。更多信息:我在Ruby 1.9.3 rails 3.2.13上。謝謝。 –

0

這原來是一個IDE問題,文件我看到名從textmate ui不同於我從終端看到的。修改後我重命名文件。