Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8521387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:48:36+00:00 2026-06-11T06:48:36+00:00

I’m working on integrating my Rails 3.1 app running Devise for user authentication with

  • 0

I’m working on integrating my Rails 3.1 app running Devise for user authentication with my iOS app. I’d like the user to be able to register from the application, and then I can store those credentials to login later.

Using RestKit, I do this:

-(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"=>"test1@test.com"}
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)

I get a 422 error, and my user is not created. The response my iOS app gets is: Response: {"email":["can't be blank"],"password":["can't be blank"]}. But the password and email isn’t blank, the server got them successfully. So, something isn’t working right, and I’m not sure where to go. How can I create the user using JSON?

Thanks for helping!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:48:38+00:00Added an answer on June 11, 2026 at 6:48 am

    Your rails app is expecting JSON in this form :

    {"user":{"email":"test@example.com", "password":"Test123", "password_confirmation":"Test123"}}
    

    But by default RestKit is sending this :

    {"email":"test@example.com", "password":"Test123", "password_confirmation":"Test123"}
    

    To add “user” you just need to set the rootKeyPath like this:

    RKObjectMapping *userSerializationMapping = [userMapping inverseMapping];
    userSerializationMapping.rootKeyPath = @"user";
    [[RKObjectManager sharedManager].mappingProvider setSerializationMapping:userSerializationMapping forClass:[User class]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.