I m 努力将我的铁路3.1与我方言的用户认证连接起来。 我同用户一样,能够从申请中登记,然后我可以储存这些证书,以便日后登记。
使用休息 我这样做:
-(IBAction)registerUser:(id)sender {
NSDictionary *params = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:
self.email.text,
self.password.text,
self.confirmPassword.text,
nil]
forKeys:[NSArray arrayWithObjects:
@"email",
@"password",
@"password_confirmation",
nil]];
[[RKClient sharedClient] post:@"/users.json" params:params delegate:self];
}
The /users.json
url goes to: user_registration POST /users(.:format) {:action=>"create", :controller=>"devise/registrations"}
(according to rake routes). It appears that the post call accepts different formats, so I assume it will accept JSON. My Post request is serialized as JSON, and sent off. The server gets it, and this is the log:
Started POST "/users.json" for 129.21.84.10 at 2012-01-12 15:33:57 -0500
Processing by Devise::RegistrationsController#create as JSON
Parameters: {"password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "email"=>"[email protected]"}
WARNING: Can t verify CSRF token authenticity
User Load (0.9ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
(0.3ms) BEGIN
(0.2ms) COMMIT
(0.2ms) BEGIN
(0.4ms) ROLLBACK
Completed 422 Unprocessable Entity in 93ms (Views: 3.8ms | ActiveRecord: 10.2ms)
我有422个错误,我的用户没有产生。 我方言的答复是:Response:{“email”:[“can t be blank”],“password”:[“can t be blank”]
。 但是,密码和电子邮件是空白,服务器是成功使用的。 因此,有些是工作权,我不敢肯定到哪里去。 我如何利用JSON创建用户?
感谢帮助!