I have a rails application running on a shared server. As I can''t install gems on it, I was going to put my own lib on the server if it couldn''t find the gem. My code was as follows (in the controller) begin require "rubygems" require "payment" rescue $: << "/home/username/rubylib" require "payment" end The problem is that the rescue doesn''t get processed. When it hits the require at line 3, the app dies. I know that the code from line 5 ($: << ...) works as I''ve tested it with irb as well as put it standalone in the controller on the shared server. If the rescue were processed, everything would be fine. Does anyone know how to get a recovery in this situation? Thanks in advance ---Michael -- 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 -~----------~----~----~----~------~----~------~--~---
dblack-TKXtfPMJ4Ozk1uMJSBkQmQ@public.gmane.org
2006-Dec-11 15:07 UTC
Re: rescueing require
Hi -- On Mon, 11 Dec 2006, Michael Satterwhite wrote:> > I have a rails application running on a shared server. As I can''t > install gems on it, I was going to put my own lib on the server if it > couldn''t find the gem. My code was as follows (in the controller) > > begin > require "rubygems" > require "payment" > rescue > $: << "/home/username/rubylib" > require "payment" > end > > The problem is that the rescue doesn''t get processed. When it hits the > require at line 3, the app dies. I know that the code from line 5 ($: << > ...) works as I''ve tested it with irb as well as put it standalone in > the controller on the shared server. If the rescue were processed, > everything would be fine. > > Does anyone know how to get a recovery in this situation?Yes: you need: rescue LoadError rescue by itself only catches StandardError and its descendants. David -- Q. What''s a good holiday present for the serious Rails developer? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) aka The Ruby book for Rails developers! Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.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 -~----------~----~----~----~------~----~------~--~---
> -----Original Message----- > From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of > Michael Satterwhite > Sent: Monday, December 11, 2006 8:01 AM > To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > Subject: [Rails] rescueing require > > > > I have a rails application running on a shared server. As I > can''t install gems on it, I was going to put my own lib on > the server if it couldn''t find the gem. My code was as > follows (in the controller) > > begin > require "rubygems" > require "payment" > rescue > $: << "/home/username/rubylib" > require "payment" > end > > The problem is that the rescue doesn''t get processed.<snip> A rescue clause without an explicit error class defaults to StandardError. A failed require raises a LoadError, which is not a subclass of StandardError. Change ''rescue'' to ''rescue LoadError'' and it should work as expected. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ryan.raaum-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Dec-11 15:46 UTC
Re: rescueing require
On Dec 11, 10:01 am, Michael Satterwhite <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I have a rails application running on a shared server. As I can''t > install gems on it, I was going to put my own lib on the server if it > couldn''t find the gem. My code was as follows (in the controller) > > begin > require "rubygems" > require "payment" > rescue > $: << "/home/username/rubylib" > require "payment" > end > > The problem is that the rescue doesn''t get processed. When it hits the > require at line 3, the app dies. I know that the code from line 5 ($: << > ...) works as I''ve tested it with irb as well as put it standalone in > the controller on the shared server. If the rescue were processed, > everything would be fine. > > Does anyone know how to get a recovery in this situation? > Thanks in advance > ---MichaelIf I remember correctly, gems and rails plugins have the same basic structure (as far as loading goes) and you can unpack a gem into the vendor/ directory. This would seem to be easier than what you''re trying here... -r> > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---