Hi, I recently saw the light and have moved my storage from the server to the wonderful Amazon S3 service. I am also using the equally great attachment_fu plugin. I would like to store the uploaded files in a path such as: /photos/[user_id]/[photo.id].jpg Instead of the default: /photos/[photo.id]/[filename] Has anyone customised the path like this? Any tips or pointers? Thanks, GiantCranes -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 3/24/07, Giant Cranes <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi, > > I recently saw the light and have moved my storage from the server to > the wonderful Amazon S3 service. I am also using the equally great > attachment_fu plugin. > > I would like to store the uploaded files in a path such as: > > /photos/[user_id]/[photo.id].jpg > > Instead of the default: > > /photos/[photo.id]/[filename] > > Has anyone customised the path like this? Any tips or pointers? > > Thanks, > GiantCranes >You can just redefine the full_filename method to fit your custom needs. -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rick Olson wrote:> > You can just redefine the full_filename method to fit your custom needs. >Thanks for point out that Rick, I have tried doing the following (Photo belongs to Vehicle belongs to Seller): def full_filename return "photos/#{self.vehicle.seller.id}/#{self.vehicle.id}/#{id}" + File.extname(filename) end This works on photos that have already been saved, but throws an exception when uploading new photos: ''You have a nil object when you didn''t expect it! The error occurred while evaluating nil.seller'' This is puzzling to me, as the photo does have a Vehicle ion the controller: def upload_vehicle_photo vehicle = Vehicle.find(params[:id]) @photo = Photo.new(params[:photo]) vehicle.photos << @photo if @photo.save flash[:information] = ''The photo was successfully uploaded.'' end redirect_to :action => ''edit_vehicle_photos'', :id => params[:id] end Am I doing anything obviously wrong here? Thanks for any insight and for providing this great plugin. GiantCranes -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I posted a short guide on how to do this at http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/6a4aa492722da26a?hl=en Eric --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Eric Northam wrote:> I posted a short guide on how to do this at > http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/6a4aa492722da26a?hl=en > > EricThanks Eric, that look like exactly what I need. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---