在生產站點中,我有一個用路徑start#index
定義的主頁。禁用所有XML視圖
這個按預期工作。
現在,一些抓取工具正在掃描頁面,例如/crossdomain.xml
,這將觸發start
控制器運行並嘗試返回XML視圖。
不幸我沒有定義它。作爲這樣的XML視圖或模板或任何東西,會產生錯誤信息(通過電子郵件,所以這是很煩人):
[Exception] start#index (ActionView::MissingTemplate) "Missing template
start/index with {:handlers=>[:rjs, :rhtml, :builder, :rxml, :erb],
:formats=>[:xml], :locale=>[:crossdomain, :en]} in view paths
所以我想有2個選擇:
- 在此應用中禁用所有的XML/JSON並呈現默認的404頁面。
- 創建一個虛擬的XML視圖。
我寧願選擇第一個選項,但我不確定如何做到這一點?感謝您提出建議或鏈接到最佳做法。
編輯,根據要求輸出rake routes
。我在第二個最後一行看到一些錯誤,我猜?
new_editor_session GET /editors/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
editor_session POST /editors/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_editor_session GET /editors/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
/auth/:provider/callback(.:format) {:action=>"create", :controller=>"sessions"}
signout /signout(.:format) {:action=>"destroy", :controller=>"sessions"}
photo_of_week_submissions GET (/:locale)/submissions/photo_of_week(.:format) {:action=>"photo_of_week", :controller=>"submissions"}
select_photo_of_week_submission GET (/:locale)/submissions/:id/select_photo_of_week(.:format) {:action=>"select_photo_of_week", :controller=>"submissions"}
accept_submission GET (/:locale)/submissions/:id/accept(.:format) {:action=>"accept", :controller=>"submissions"}
submissions GET (/:locale)/submissions(.:format) {:action=>"index", :controller=>"submissions"}
POST (/:locale)/submissions(.:format) {:action=>"create", :controller=>"submissions"}
new_submission GET (/:locale)/submissions/new(.:format) {:action=>"new", :controller=>"submissions"}
edit_submission GET (/:locale)/submissions/:id/edit(.:format) {:action=>"edit", :controller=>"submissions"}
submission GET (/:locale)/submissions/:id(.:format) {:action=>"show", :controller=>"submissions"}
PUT (/:locale)/submissions/:id(.:format) {:action=>"update", :controller=>"submissions"}
DELETE (/:locale)/submissions/:id(.:format) {:action=>"destroy", :controller=>"submissions"}
login (/:locale)/login(.:format) {:to=>#<Proc:0x0000000103871[email protected]/Library/Ruby/Gems/1.8/gems/actionpack-3.0.7/lib/action_dispatch/routing/mapper.rb:366>}
design (/:locale)/design(.:format) {:action=>"design", :controller=>"page"}
gallery (/:locale)/gallery(.:format) {:action=>"gallery", :controller=>"page"}
features (/:locale)/features(.:format) {:action=>"features", :controller=>"page"}
competition (/:locale)/competition(.:format) {:action=>"index", :controller=>"competition"}
facebook_albums (/:locale)/facebook-albums(.:format) {:action=>"facebook_albums", :controller=>"competition"}
facebook_photos (/:locale)/facebook-photos(.:format) {:action=>"facebook_photos", :controller=>"competition"}
facebook_upload (/:locale)/facebook-upload(.:format) {:action=>"facebook_upload", :controller=>"competition"}
root (/:locale)(.:format) {:action=>"index", :controller=>"start"}
root /(.:format) {:action=>"index", :controller=>"start"}
爲什麼不直接生成sitemap.xml並強制抓取工具抓取正確的網址,而不是以前緩存和無效的網址。 – 2011-04-28 05:21:14
你可以發佈你的routes.rb嗎? – thekindofme 2011-04-28 05:27:03