Has anyone successfully used attachment_fu with rails 2.3 nested model
forms?

I've never used attachment_fu before so I may be doing something wrong
there not sure.  Here's what I've got:

class Product < ActiveRecord::Base
  has_one :cover_image
  accepts_nested_attributes_for :cover_image, :allow_destroy => true
end

class CoverImage < ActiveRecord::Base
  has_attachment :content_type => :image,
                            :storage          => :file_system,
                            :path_prefix    => 'public/images/covers
end

standard rest controller action:
  def create
    @product = Product.new(params[:product])

    respond_to do |format|
      if @product.save
        flash[:notice] = 'Product was successfully created.'
        format.html { redirect_to(@product) }
        format.xml  { render :xml => @product, :status
=> :created, :location => @product }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @product.errors, :status
=> :unprocessable_entity }
      end
    end
  end

and the new form:

<% form_for(:product, :url => products_path, :html => { :multipart =>
true }) do |f| %>
  ...
  ...
    <% f.fields_for(:cover_image) do |c| %>
      <%= c.file_field :uploaded_data %>
    <% end %>
  ...
  ...
<% end %>

On submitting the form I get this error:
ActiveRecord::AssociationTypeMismatch (CoverImage(#70223327600060)
expected, got HashWithIndifferentAccess(#70223341431440)):

Any thoughts greatly appreciated!
Tim
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to