I know rails has super easy ways of doing this but I'm not sure
exactly how.

I have one model "LineItems" which has_many :order_attachments.
OrderAttachment is using paperclip, but I'm thinking this would be the
same regardless. I'm wondering. In my LineItem "new" view how can I
add one (or more) OrderAttachment within the same form.

Lets say LineItem has an "order_name" attribute. And each
OrderAttachment has a "attachment" (which is currently a paperclip
attachment). I'm doing the following, and the image gets uploaded in
the log, but never saves to OrderAttachment. Any ideas? Is this the
correct way to do it? Also (if anyone knows off hand) is there a quick
way to expand this so the user can upload as many attachments as they
want?

<%= form_for(@line_item, :html => { :multipart => true }) do |f| %>
  <%= fields_for :order_attachments do |attachment_form| %>
     <%= attachment_form.file_field :attachment %>
  <% end %>
  <%= f.text_field :item_name %>
  <%= f.submit %>
<% end %>

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to