我使用 Devise 设置了一个 rails 3.2.11 应用程序进行身份验证。我想使用ember.js作为 mvc 框架。
当我对 POST /users.json 路由发起 ajax 调用时,我得到 406 Not Acceptable。
这是我的ajax调用:
urlBase : '/users'
signup : (username, email, password, passwordConfirmation) ->
$.ajax
url: "#{@.get('urlBase')}.json"
type: "POST"
dataType: "json"
data:
"user[username]": username
"user[email]": email
"user[password]": password
"user[password_confirmation]": passwordConfirmation
success: (data) ->
alert('Completed sign up process: '+ JSON.stringify(data));
@errorMsg = "Signed up successfully."
error: (jqXHR, textStatus, errorThrown) ->
alert "Error completing sign up: " + textStatus + " error: " + errorThrown
以下是日志:
Started POST "/users.json" for 127.0.0.1 at 2013-01-14 14:38:57 +0100
Processing by Devise::RegistrationsController#create as JSON
Parameters: {"user"=>{"username"=>"obo", "email"=>"obo@obo.dv", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}}
(1.3ms) begin transaction
User Exists (1.3ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'obo@obo.dv' LIMIT 1
(0.1ms) rollback transaction
Completed 406 Not Acceptable in 311ms (ActiveRecord: 2.6ms)
我不明白为什么会这样。