I''m trying to add a link to download a zip file. I created a controller method that makes the call to send_file: def getzip send_file ''file.zip'' end When I navigate to this link I get a MissingFile exception. The file definitely exists (and U triple-checked paths and spelling) and the permissions are 644. I tried moving it to the /public folder and updating the getzip method to grab it from here, but I still get the same exception. Is there any configuration with rails or apache I can check? I have used send_data in other modules without any problems, so I''m scratching my head on this one. Thanks. Mike --~--~---------~--~----~------------~-------~--~----~ 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 17 Dec 2007, at 03:24, Mike wrote:> > I''m trying to add a link to download a zip file. I created a > controller method that makes the call to send_file: > > def getzip > send_file ''file.zip'' > end >A path like that will be relative to your current working directory (usually the same as you rails_root). Try using an absolute path/not relying on the current working directory (ie /foo/bar/file.zip or RAILS_ROOT + ''/file/zip''. File.expand_path ''file.zip'' should tell you exactly what path it''s trying to access. Fred> When I navigate to this link I get a MissingFile exception. The file > definitely exists (and U triple-checked paths and spelling) and the > permissions are 644. I tried moving it to the /public folder and > updating the getzip method to grab it from here, but I still get the > same exception. Is there any configuration with rails or apache I can > check? I have used send_data in other modules without any problems, > so I''m scratching my head on this one. > > Thanks. > > Mike > --~--~---------~--~----~------------~-------~--~----~ > 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/ruby--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks! Using expand_path ''file.zip'' showed it was looking for it in / public. I suspected it was looking there, but I was using ''/public/ code.zip'' instead of just the filename. Mike On Dec 16, 11:08 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 17 Dec 2007, at 03:24, Mike wrote: > > > > > I''m trying to add a link to download a zip file. I created a > > controller method that makes the call to send_file: > > > def getzip > > send_file ''file.zip'' > > end > > A path like that will be relative to your current working directory > (usually the same as you rails_root). Try using an absolute path/not > relying on the current working directory (ie /foo/bar/file.zip or > RAILS_ROOT + ''/file/zip''. > File.expand_path ''file.zip'' should tell you exactly what path it''s > trying to access. > > Fred > > > When I navigate to this link I get a MissingFile exception. The file > > definitely exists (and U triple-checked paths and spelling) and the > > permissions are 644. I tried moving it to the /public folder and > > updating the getzip method to grab it from here, but I still get the > > same exception. Is there any configuration with rails or apache I can > > check? I have used send_data in other modules without any problems, > > so I''m scratching my head on this one. > > > Thanks. > > > Mike > > --~--~---------~--~----~------------~-------~--~----~ > > 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 athttp://groups.google.com/group/ruby--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---