heres my controller action:
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 => {开发者_如何学C :errors => "errors" } }
end
end
end
When I have no errors, the user path is returned to uploadify onComplete. But when I try to pass a string back to onError I get redirected to
ActionController::RoutingError (No route matches "/undefined"):
Rendered /Users/ddayan/.rvm/gems/ruby-1.9.2-p136/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.8ms)
Any idea what am I doing wrong??
Edit: Ok, I didn't think it through, if I render json than it goes to onComplete. So my new question is how do I return the error message to onError????
Edit2: So I changed the format to JS
format.js { render :text => "ERROR", :status => 403 }
I get the error status in the info field inside errorObj, but I don't have responseText
Object
info: 403
type: "HTTP"
__proto__: Object
精彩评论