Updating image from a complex form

1 view
Skip to first unread message

SH

unread,
Nov 6, 2009, 8:53:12 AM11/6/09
to Paperclip Plugin
In my project I have the following three models
Post, Category, Design.
Category has many Posts
CustomDesign has many Posts.
Category has one Design

Design Model has the follolwing.
has_attached_file :header
has_attached_file :footer

I am taking in the header and footer images of design from the Posts
form.
i.e form_for @post has a fields_for :design_attributes with
file_fields for header an footer.

I have a setter method to set attributes as follows.
def design_attributes=(attributes)
if(!category.design)
design = category.build_design(attributes)
else
design = category.design
design.attributes = attributes
end
end


With the above code i am able to save the image in Design model.
But design.attributes = attributes does not seem to work.
How do i update the images in my design model?
Reply all
Reply to author
Forward
0 new messages