继承我的控制器行动:
def create
#logger.debug("Time.now is #{Time.now}")
new_params = coerce(params)
logger.debug new_params.inspect
params[:user] = new_params[:user]
@user = User.api_create(params[:user])
logger.info @user.inspect
# redirect_to @user
respond_to do |format|
if @user.save
format.html {redirect_to @user}
format.json {render :json => { :user => user_path(@user) } }
else
format.html {redirect_to :controller => "application", :action => "index"}
format.json {render :json => { :errors => "errors" } }
end
end
end
当我没有错误时,用户路径将返回到uploadify onComplete。但是当我尝试将字符串传回onError时,我被重定向到
ActionController :: RoutingError(No route匹配“/ undefined”):
渲染 /Users/ddayan/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb 在救援/布局(1.8ms)内
知道我做错了什么吗?
编辑:好的,我没有想到,如果我渲染json而不是onComplete。所以我的新问题是如何将错误消息返回到onError ????
Edit2:所以我将格式改为JS
format.js { render :text => "ERROR", :status => 403 }
我在errorObj中的info字段中获取错误状态,但我没有responseText
Object
info: 403
type: "HTTP"
__proto__: Object