title: Problems with RestKit and RKParams
body: <p>I've got a relatively simple Rails app that takes a form with nested params that includes a photograph. It looks like this:</p>
  
  <pre><code>class List &lt; ActiveRecord::Base
    has_many :list_items
    has_many :people, through: list_items
  end
  
  class ListItem &lt; ActiveRecord::Base
    belongs_to :list
    belongs_to :person, autosave: true
  
    has_attached_file :picture,
      :storage =&gt; :s3,
      :bucket =&gt; 'myfreebielist',
      :s3_credentials =&gt; {
        :access_key_id =&gt; ENV['S3_KEY'],
        :secret_access_key =&gt; ENV['S3_SECRET']
      }
  
  
    def autosave_associated_records_for_person
      if new_person = Person.find_by_name(Person.name) then
        self.person = new_person
      else
        self.person.save!
      end
    end
  end
  
  class Person &lt; ActiveRecord::Base
    has_many :list_items
  end
  </code></pre>
  
  <p>I set up a test new form, just to make sure everything works, and it does, nice and pretty:</p>
  
  <pre><code>&lt;%= form_for @list do |f| %&gt;
    List name: &lt;%= f.text_field :name %&gt;&lt;br/&gt;
    &lt;%= f.fields_for :list_items do |lif| %&gt;
      &lt;%= lif.fields_for :person do |pif| %&gt;
      Person name: &lt;%= pif.text_field :name %&gt;
      &lt;% end %&gt;
      Picture: &lt;%= lif.file_field :picture %&gt;
      &lt;br/&gt;
    &lt;% end %&gt;
    &lt;%= f.submit %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>OK, so I want to be able to post a new list, with list items (and their related picture images), as well as the person for that list item. I have this code that I'm testing with in Objective C:</p>
  
  <pre><code>NSMutableDictionary *listParams = [NSMutableDictionary dictionary];
  [listParams setValue:@"Test One" forKey:@"name"];
  
  NSMutableDictionary *listItems = [NSMutableDictionary dictionary];
  
  // Generate each list item -- a person and a photo.
  NSDictionary *person1 = [NSDictionary dictionaryWithKeysAndObjects:@"name", @"John Smith", nil];
  NSDictionary *listItem1 = [NSDictionary dictionaryWithKeysAndObjects:@"person_attributes", person1, nil];
  [listItems setValue:listItem1 forKey:@"0"];
  [listParams setValue:listItems forKey:@"list_items_attributes"];
  
  NSMutableDictionary *params = [NSMutableDictionary dictionary];
  [params setValue:listParams forKey:@"list"];
  
  [[RKClient sharedClient] post:@"/lists" params:params delegate:self];
  </code></pre>
  
  <p>This also works fine, with the notable absence of the picture.</p>
  
  <p>Now, I understand that using an <code>RKParams</code> instead of an <code>NSDictionary</code> is how you're supposed to handle this type of request, but when I post using an <code>RKParams</code> there is all manner of strange things arriving at the rails side -- lots of <code>\n</code> newlines, spaces and things around the keys. I tried using an <code>RKParams</code> with an attachment as part of <code>person1</code>, but it seems to just send the string representation of the name of the object RKParams object.</p>
  
  <p>I feel like I'm so, so close but I've been hitting my head against this for hours now. Any help would be appreciated.</p>
  
  <p>Environment: Xcode 4.3, Rails 3.2.1.</p>