我想在一個Rails 3.2應用程序上設置jquery文件上傳,在guide之後。如何調試一個POST 500內部服務器錯誤
一切幾乎是可以正常使用但,當我點擊「開始上傳」我在Chrome中看到的控制檯錯誤:
POST http://testapp.dev/photos 500 (Internal Server Error)
在日誌中我得到:
ActionView::MissingTemplate (Missing template photos/create, application/create with {:locale=>[:en], :formats=>[:js, :html], :handlers=>[:erb, :builder, :coffee]}.
我已經通過控制器用一個細齒梳,但我無法弄清楚是什麼導致這個錯誤或爲什麼它尋找一個創建部分。什麼是調試這個系統的方法?
感謝
編輯
我控制器操作是這樣的:
class PhotosController < ApplicationController
def index
@photos = Photo.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @photos }
format.json { render :json => @photos.collect { |a| a.to_jq_upload }.to_json }
format.js { render :json => @photos.collect { |a| a.to_jq_upload }.to_json }
end
end
def show
@photo = Photo.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @photo }
format.json { render :json => @photo }
format.js
end
end
def new
@photo = Photo.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @photo }
format.json { render :json => @photo }
format.js
end
end
def edit
@photo = Photo.find(params[:id])
end
def create
@photo = Photo.new(params[:photo])
respond_to do |format|
if @photo.save
format.html {
render :json => [@photo.to_jq_upload].to_json,
:content_type => 'text/html',
:layout => false
}
format.json { render :json => [ @photo.to_jq_upload].to_json }
format.js
else
format.html { render :action => "new" }
format.xml { render :xml => @photo.errors, :status => :unprocessable_entity }
format.json { render :json => [ {:error => "An error was encountered while processing your photos. Please try again."}], status: 304 }
format.js
end
end
end
def update
@photo = Photo.find(params[:id])
respond_to do |format|
if @photo.update_attributes(params[:photo])
format.html { redirect_to(@photo, :notice => 'Asset was successfully updated.') }
format.xml { head :ok }
format.json { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @photo.errors, :status => :unprocessable_entity }
format.json { render json: @photo.errors, status: :unprocessable_entity }
end
end
end
# DELETE /assets/1
# DELETE /assets/1.xml
def destroy
@photo = Photo.find(params[:id])
@photo.destroy
respond_to do |format|
format.html { redirect_to(photos_url) }
format.xml { head :ok }
format.json { render :json => true }
format.js
end
end
end
應用程序日誌中的任何內容? – Stefan
您是否檢查過您的應用程序的日誌?我不知道你的生產類型。在heroku上是'heroku logs'或'heroku logs -n 500'來檢索500行。 – jdoe
是的,我得到'ActionView :: MissingTemplate(缺少模板照片/創建,應用程序/創建與{:語言環境=> [:恩],:格式=> [:js,:html],:handlers => [ :。爲什麼它尋找一個創建的部分? –