Q:

Best practices: error handling Ruby(Rails) to iOS(AFNetworking)

New to RoR, not new to iOS.
So I'm using AFNetworking to handle all of my api calls. For example: 
[[TJAPIClient shared] GET:@"api/taxonomies"
               parameters:nil
                  success:^(AFHTTPRequestOperation *operation, id responseObject)
{
    NSMutableArray *taxonomies = [NSMutableArray arrayWithCapacity:[responseObject[@"taxonomies"] count]];
    [responseObject[@"taxonomies"] each:^(NSDictionary *taxonomyInfo)
    {
        TJTaxonomy *taxonomy = [TJTaxonomy modelWithRemoteDictionary:taxonomyInfo];
        [taxonomies addObject:taxonomy];
    }];

    if (block) block(taxonomies, nil);
}
                  failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
    NSLog(@"Error fetching taxonomies: %@", error);
    [UIAlertView showAlertViewWithTitle:@"Server Error"
                                message:error.localizedDescription
                      cancelButtonTitle:nil
                      otherButtonTitles:nil
                                handler:nil];
    if (block) block(nil, error);
}];

And on RoR, nothing fancy:
def create
  @user = User.new(user_params)
  respond_to do |f|
    if @user.save
        f.html {}
        f.json { render json: @user }
    else
        f.html {}
        f.json { render json: @user.errors.full_messages }
    end
  end
end

As it stands, the code that is written above returns errors through the success block and the data looks like this:
{
    errors = (
        @"Email can't be blank",
        @"Password can't be blank"
    )
}

So all I want to know is how I can send these errors through the failure block, as well as send the respective errors as an NSError object. If that's not possible, then perhaps some best practices for this kind of thing. Again, I'm very new to the RoR world (loving it, though!).
Thank you!

A:

You'll have to check the responseObject of the success callback block if you want to handle those errors.
if (responseObject[@"errors"])
    NSLog(@"Oh noes!");
}

The error block is a passthrough1 for NSURLSessionTaskDelegate and will be when URLSession:task:didCompleteWithError: gets called with an error. 
NSURLSessionTaskDelegate

Server errors are not reported through the error parameter. The only errors your delegate receives through the error parameter are client-side errors, such as being unable to resolve the hostname or connect to the host.

Well, it will also get called on any serialization errors from the response serializer. 
You can take a look at AFURLSessionManagerTaskDelegate's URLSession:task:didCompleteWithError: method to see how it works.

