I am showing image preview after uploading images.My view contains table of persons with name ,email id,file upload and image preview.And on submit button it will save all images to respective one.I am stuck how to save hash of each image to respective one through paperclip. I successfully get hash with each person id as key. I have two controllers Person and Image and this preview and save functionality work on new and create of image.
Code for Image controller:
def new
@people = Person.where("avatar_file_name is ?",nil)
end
def create
@people = Person.where("avatar_file_name is ?",nil)
[email protected]
u=Array.new
@people.each do |e|
u.push(e.id)
end
h=Hash.new
h=params
u.each do |x|
@newimage=h["#{x}"]
######## Here in @newimage we get hash of image
end`
end
end
What I have to write after getting hash of each images? Anyone needs some more description they can ask.......... Thanks in advance
got solution......very easy one
u.each do |x|
@person = Person.find(x)
@person.update_attribute(:avatar,h["#{x}"])
end
It's working fine