Hello!

This is old thread but i need some help!
I'd like to take foz's solution for my project using attachment_fu.
I am going to make link to remake thumbs in my view, and i don't need to 
rake task.
But I don't know where I should put  'remake_thumbnails!' method in.
I've tried to put the method in 'attachment_fu.rb', but it's not working.
Should I put it in my upload model or wherelse?  
And how can I call this method from view or controller?
I am a really beginner in web development using Rails and Ruby.
 it will many thanks if you help me.



2009년 11월 30일 월요일 오후 1시 15분 33초 UTC+9, foz 님의 말:
>
> I use a method that rebuilds in my attachment model class: 
>
>   # use attachment_fu protected methods to remake thumbs 
>   def remake_thumbnails! 
>     self.thumbnails.each {|thumb| thumb.destroy} 
>     temp_file = create_temp_file 
>     attachment_options[:thumbnails].each do |suffix, size| 
>       self.create_or_update_thumbnail(temp_file, suffix, *size) 
>     end 
>   end 
>
> If you want a rake task, just loop through all your attachment records 
> and call it. I'm using something similar to this: 
>
> namespace :images do 
>   desc "Rebuild all thumb images made by attachment_fu" 
>   task :rebuild_thumbnails => :environment do 
>     conditions =  "(whatever you need)" 
>     count = Image.count(:all, :conditions => conditions) # image is an 
> attachment_fu model 
>     done = 0 
>     chunk_size = 500 
>     (0...(count/chunk_size)).each do |i| 
>       Image.find(:all, :offset => i*chunk_size, :limit => 
> chunk_size, :conditions => conditions).each do |image| 
>         done = done + 1 
>         # next if image.id < 46520 #  to resume a stopped run 
>         image.remake_thumbnails! 
>         percent = "%.2f" % ((done/count.to_f)*100) 
>         puts "#{i.id} #{percent}% done" 
>       end 
>     end 
>   end 
>
>
> On Nov 26, 3:47 pm, eugenio <[email protected]> wrote: 
> > i'm using this plugin for files and images uploads. 
> > it has a very useful feature that generatethumbnailsof every 
> > uploaded image, based on the geometry given in the model definition. 
> > now i want to change the size of one of the thumbnail: how can i re- 
> > generate them for the already saved image? 
> > 
> > i found thishttp://github.com/kete/kete/blob/master/lib/tasks/tools.rake 
> > but i don't understand how to use it. 
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/63b4f6af-482f-472e-adb9-01167412a6e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to