andresmax-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Nov-14  16:35 UTC
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)
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
andresmax-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Nov-16  14:50 UTC
Re: attachment_fu: setting the default image
anyone ? --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
*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, "andres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <andres...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> anyone ?--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---