1
roamlog 2011-11-30 14:55:39 +08:00
错误信息最好全一点。。。
|
2
tysx 2011-11-30 14:59:05 +08:00
给url加上后缀,例如.xml, .html试试
|
3
shooter OP user_controller.rb
def new @user = User.new respond_to do |format| format.html # new.html.erb format.json { render json: @user } end end def create #if request with JSON, which means multi-part will be used logger.debug "create...." logger.debug request.headers['Accept'] if(request.headers['Accept'] == "application/json") data = ActiveSupport::JSON.decode(params[:user]) @user = User.new(data) else @user = User.new(params[:user]) end respond_to do |format| if @user.save format.html { redirect_to(users_url, :notice => "User #{@user.name} was successfully created.") } #format.json { render json: @user, status: :created, location: @user } #format.json { render :json => @user.as_json(:only => [:name])} #render :nothing => true format.json {render json: @user.as_json(:only => [:id, :hashed_password])} else format.html { render action: "new" } format.json { render json: @user.errors}# status: :unprocessable_entity } end end end -------------------------------------------------------------------------------------------------------- new.html.erb <%= form_for(@user, :html => { :multipart => true }) do |f| %> .................................................. <% end> ------------------------------------------------------------------------------ routes.rb resources :users do resources :trips do resources :spots do resources :photos end end end |
4
roamlog 2011-11-30 15:11:39 +08:00
我是要看错误信息,不管是在终端的还是 log 文件里的
|
5
shooter OP |
6
shooter OP @roamlog 没有错误信息 不报错 提示信息
Started GET "/users/new.html" for 127.0.0.1 at 2011-11-30 15:19:26 +0800 Processing by UsersController#new as HTML start authorize Completed 406 Not Acceptable in 0ms 貌似输出格式的问题?? 可没做什么特殊格式处理啊 |
7
chloerei 2011-11-30 15:32:57 +08:00
start authorize 是什么?用了什么插件?
|
8
shooter OP @chloerei ApplicationController.rb定义的一个方法
貌似跟这有关 UsersController.rb skip_before_filter :authorize, :only => [:index, :show, :list,] |
9
tysx 2011-11-30 18:43:29 +08:00
把 GET "/users/new" 改成GET "/users/new.html"或者GET "/users/new.json"
也不行吗? |