This has been a head-banger for me. I have looked at all of the similar questions on SO and none have proved satisfactory. Here's my go at it.
I have a perfectly fine rails 3 app setup with Authlogic.
I have been using Objective Resource (http://iphoneonrails.com/) to connect my iPhone app and my Rails app, and it has been working fine.
Now is the time to add authentication, and I cannot figure it out.
I have a UserSession class in my iPhone project with a username and password field. When the app launches, I present a login screen with username and password fields. Upon clicking a button, the iPhone app attempts to create the UserSession.
I took my code for doing that from http://www.corprew.org/blog/2010/01/27/authlogic-and-objectiveresource/
us.username = usernameField.text;
us.password = passwordField.text;
NSError * err = nil;
if(![us saveRemoteWithResponse:&err])
{
NSLog(@"%d", err);
NSLog(@"whoops, error");
}
When I run that code, the Log shows "0" and "whoops, error" meaning that the UserSession did not save. This occurs for both correct and incorrect logins.
Additionally, I have placed token comments in saveRemote ("I'm in saveRemote" etc.) and those never appear in my log.
Any ideas here?
If you want me to post anymore code, let me know. I will be up all night with this one.
Question resolved.
Don't use ObjectiveResource :-)
Switched to ASIHTTP and it's working fine for my needs right now.