[報錯紀錄]ActionController::UnknownFormat in Admin::JobsController#edit

Published on:

位置:
http://localhost:3000/admin/jobs/1/edit

錯誤訊息:
Admin::JobsController#edit is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: [] NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not… nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.

問題描述:
打完admin/job的CRUD 檢查各個功能時發現edit出錯

debug思路:
Admin::JobsController#edit is missing a template for this request format and variant.
UnknownFormat in Admin::JobsController#edit
以上兩句話看起來像是說 沒有edit的表格
於是去找edit的view的頁面看是不是表格型態打錯

錯誤排除方式:
發現是沒有建立到app/views/admin/jobs/edit.html.erb
建立後正常~

心得:
再打CRUD時一定要controller一個def打完就去打對應的view,一次打完所有def再去打對應的view就會再發生類似的錯誤

Comments

comments powered by Disqus