我正在尝试按照本指南在 Rails 3.2 应用程序上设置 jquery 文件上传。
一切都几乎完美无缺,但是,当我点击“开始上传”时,我在 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