ruby on rails - Completed 406 Not Acceptable in 773ms -


my client app sends json encoded post rails server server shows 406 error , doesn't respond json.

userscontroller create

# post /users # post /users.json def create   @user = user.new(params[:user])    respond_to |format|     if @user.save       format.html { redirect_to @user, notice: 'user created.' }       format.json { render json: @user, status: :created, location: @user }     else       format.html { render action: "new" }       format.json { render json: @user.errors, status: :unprocessable_entity }     end   end end 

rails console:

started post "/users.json" 127.0.0.1 @ 2013-05-21 16:38:47 +0100 processing devise::registrationscontroller#create json   parameters: {"user"=>{"name"=>"", "available"=>"true", "email"=>"", "sex"=>"male", "password"=>"[filtered]", "password_confirmation"=>"[filtered]"}} warning: can't verify csrf token authenticity    (0.2ms)  begin transaction   user exists (0.3ms)  select 1 one "users" "users"."email" = '' limit 1    (0.2ms)  rollback transaction completed 406 not acceptable in 773ms (activerecord: 6.1ms) 

can me?

going try answer while later in case sees it. i've run problem on , on when i've had json format option @ bottom of controller (like in example):

respond_to |format|   format.json { render json: @user, status: :created, location: @user } end 

even when calling explicitly $.getjson on requests call json data types.

the trick found calling .json on page name.

 $.getjson('controllername-your-calling.json?', function(json){       //do stuff...  }); 

maybe helps someone.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -