title: Configuring Rails 3 + Polymorphic Image model + Paperclip and Amazon S3, No errors, but nothing uploading
body: <p>I suspect the problem lies in the way I am creating the polymorphic image attribute. I am using <code>fields_for</code> in the form.
  In this case a user can create a post and add an image using paperclip, storing it with S3.
  I am using a polymorphic <strong>image model "post_image":</strong></p>
  
  <pre><code>class PostImage &lt; ActiveRecord::Base
    belongs_to :imageable, :polymorphic =&gt; true
    #.merge(PAPERCLIP_OPS)
    has_attached_file :image, :styles =&gt; { :medium =&gt; "200x200&gt;", :thumb =&gt; "50x50&gt;" },
                              :storage =&gt; :s3, 
                              :s3_credentials =&gt; "#{Rails.root}/config/s3.yml", 
                              :path =&gt; "/:style/:id/:filename", 
                              :bucket =&gt; "zounds-dev"
    validates_attachment_presence :image
    validates_attachment_size :image, :less_than =&gt; 5.megabytes
  end
  </code></pre>
  
  <p><strong>Post Model:</strong></p>
  
  <pre><code>class Post &lt; ActiveRecord::Base
    has_many :post_images, :as =&gt; :imageable, :dependent =&gt; :destroy
    .
    .
    .
    accepts_nested_attributes_for :post_images, :reject_if =&gt; lambda { |t| t[:post_image].nil?}, :allow_destroy =&gt; true
  end
  </code></pre>
  
  <p><strong>New Post Form:</strong></p>
  
  <pre><code>=form_for( setup_post(@post,current_user), :html =&gt; { :multipart =&gt; true}) do |f|
    %dl   
      =f.fields_for :post_images do |ff|
        =ff.file_field :image
      %dt.field=f.label :name
      %dd.field=f.text_field :name
      %dt.field=f.label :description
      %dd.field=f.text_area :description
      =f.fields_for :user do |u|
        =render "user_fields", :f =&gt; u
      =f.fields_for :assignments do |ff|
        =ff.check_box :_destroy, {:checked =&gt; ff.object.persisted?}, '0','1'
        =ff.label :_destroy, ff.object.group.name
        =ff.hidden_field :group_id
      .action=f.submit "Save Post"
  </code></pre>
  
  <p><strong>The <code>setup_post</code> helper method</strong> used in the Post <code>form_for</code>: (the groups stuff isn't relevant here)</p>
  
  <pre><code>  def setup_post(post, current_user)
      groups = current_user.groups_as_owner + current_user.groups_as_member
      (groups - post.groups).each do |group|
        post.assignments.build(:group =&gt; group)
      end
      post.assignments.sort_by {|x| x.group.name }
      post_image = post.post_images.build
      post
    end
  </code></pre>
  
  <p><strong>Post controller:</strong></p>
  
  <pre><code>  def new
      @user = User.find(params[:user_id])
     #  @post = @user.posts.build
     @post = Post.new
      respond_to do |format|
        format.html # new.html.erb
        format.xml  { render :xml =&gt; @post }
      end
    end
  
  def create
      @user = current_user
      @post = @user.posts.build(params[:post])
      .
      .
      .
  end
  </code></pre>
  
  <p>I suspect the problem is that I am using <code>fields_for</code> for the post_image attribute, but I've looked all over and can't figure out what the proper way to implement a polymorphic nested image attribute is.</p>
  
  <p>I also did the <code>s3sh</code> amazon s3 console thing, and although I couldn't upload an image because I couldn't figure out how to pass in the right image path to the open() function, I connected to S3. My <code>s3.yml</code> file is set up correctly as well.</p>
  
  <p>Thanks yall,
  Brian</p>