I''m borrowing this question from a user named Spencer on the Rails
Forums. He clearly explains the issue we''re having:
"First of all, apologies, as I am probably missing something utterly
obvious.
I am trying to set up a polymorphic assets model, with attachment_fu.
Essentially attachment_fu is working as I can upload directly to the
attachment model. However when I try and upload a file from another
controller (linked polymorphically) I get errors about the
content_type etc. not being in the list.
I assume this means that the params array isn''t capturing the data?
How can I correct this?
in my asset model i have:
1. belongs_to :attachable, :polymorphic => true
(and has_attachment + validates_as_attachment)
in my product model I have:
1. has_many :assets, :as => :attachable
in the create method in my products controller is am using:
1. @asset = @product.assets.build(params[:uploaded_data])
In my new product form I have:
1. <%= file_field ''asset'',
''uploaded_data'' %>
A yaml dump of the form content
1. --- !map:HashWithIndifferentAccess html: multiparttrue commit:
Create product: !map:HashWithIndifferentAccess name: test body: test
title: test green: test category_ids: - "3" sidebar: ""
description:
test action: create controller: admin/products asset: !
map:HashWithIndifferentAccess uploaded_data: cm_logo.jpg
The errors I get:
Assets is invalid
Content type is not included in the list
Content type can''t be blank
Size is not included in the list
Size can''t be blank
Filename can''t be blank
Any help greatly appreciated."
http://www.railsforum.com/viewtopic.php?pid=23135
Thanks,
Walksalong
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---