Discussion Forums
- Topic List
- Most Recent Posts
- Sign In for more options
Thanks Ganesh,
These lines of code solved the problem: def photo_attributes=(photo_attributes) photo_attributes.each do |attributes| photos.build(attributes) if !attributes[:image].blank? end end
Hi Ganesh,
Thanks for your help, I'll show an example of my code (http://pastie.org/727904)
At the end I've included update.html.erb for testing. As you can see, I retrieve something, but I'd like to get the real photo data.
Can you help me with this?
Hi Wouter,
You can access new array(picturs) content like:
ex : Im considering edit form as:
{ :multipart => true } do |person_form| %>
First name:
Last name :
Enxisting image:
Now in your controllers :update function will be:
def update @person = Person.find(params[:id])
if @person .update_attributes(params[:person]) params[:person][:newphotos] ||= [] @personNewPhotos = params[:person][:newphotos]
@personNewPhotos.each do |newPhoto| @photo = @person.photos.new @photo.image = newPhoto @photo.save end end end
I hope this will help you..
Good Luck..!
:) :)
Hello,
I'm using paperclip to add pictures to a project. One project can have multiple pictures so I've added multiple fields. (that's working fine) But when I update a project with empty (picture)fields, paperclip is creating empty entries in the photo model.
So my question is, how can I get the newly added pictures in an array? I've tried params[:project][:data] but that isn't returning anything.
Thanks
