Attachment_fu: setting the default image

Hey everyone, quick question ,

how can I set the default image using attachment_fu? (this is not a
quesiton on how to use it, cause I got it working and the first image
is being set as default)

Thing is, I want the user to have the option to change the default
image to whichever he likes, currently I have this in the user_image
controller:

def default_image
  @image = UserImage.find(params[:id])
  @userimg = UserImage.find(:all, :conditions => ['parent_id is

null AND user_id=?’,@image.user_id])
@userimg.each do |daimg|
daimg.update_attributes(:default => false)
end
@image.set_as_default
redirect_to user_url(current_user)
end

in the model:

def set_as_default
self.default = true
self.save
end

BUT this takes way too long because it re-creates every single image
and thumbnail again…

what other way can I do this ? (where the already uploaded image dont
get re-created again)

anyone ?

Bump

I have same scenario…want to let the user change an image associated
with a product as being the default.
Using a radio button.

http://pastie.org/138562 – currently, it always sets the first image
as the default.

They should be able to pick one, or change the existing default with
radio button selection.

On Nov 16 2007, 6:50 am, “[email protected][email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs