Hello -- Is there some trick to using Net::SFTP within a Rails model? I keep getting the following error and for the life of me I can''t figure it out. The code works fine outside the model context (i.e. in a ruby console): c:/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/debug.rb:121:in `orig_open'' c:/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/debug.rb:121:in `open'' c:/ruby/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/operations/open.rb:27:in `perform'' c:/ruby/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/operations/abstract.rb:64:in `execute'' c:/ruby/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/session.rb:253:in `method_missing'' c:/ruby/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/session.rb:177:in `open_handle'' c:/ruby/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/session.rb:203:in `put_file'' The code is just: Net::SFTP.start(@sftp_server, @sftp_login, @sftp_password) do |sftp| sftp.put_file self.path, "/home/blah-blah/dir" end Cheers, Jake -- 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 -~----------~----~----~----~------~----~------~--~---
You didn''t really give us the error...just the stack trace. :) Can you tell us exactly what exception is being thrown? --Jeremy On 2/13/07, Jake Janovetz <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hello -- > > Is there some trick to using Net::SFTP within a Rails model? I keep > getting the following error and for the life of me I can''t figure it > out. The code works fine outside the model context (i.e. in a ruby > console): > > c:/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/debug.rb:121:in > `orig_open'' > c:/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/debug.rb:121:in > `open'' > c:/ruby/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/operations/open.rb:27:in > `perform'' > c:/ruby/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/operations/abstract.rb:64:in > `execute'' > c:/ruby/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/session.rb:253:in > `method_missing'' > c:/ruby/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/session.rb:177:in > `open_handle'' > c:/ruby/lib/ruby/gems/1.8/gems/net-sftp-1.1.0/lib/net/sftp/session.rb:203:in > `put_file'' > > > The code is just: > > Net::SFTP.start(@sftp_server, @sftp_login, @sftp_password) do |sftp| > sftp.put_file self.path, "/home/blah-blah/dir" > end > > > Cheers, > Jake > > -- > Posted via http://www.ruby-forum.com/. > > > >-- http://www.jeremymcanally.com/ My free Ruby e-book: http://www.humblelittlerubybook.com/book/ My blogs: http://www.mrneighborly.com/ http://www.rubyinpractice.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 -~----------~----~----~----~------~----~------~--~---
Oops. It''s just: can''t convert nil into String But it''s not from any of my stuff being ''nil''. The trace comes down to these lines in Net::SFTP::open.rb: --- # Performs the operation. def perform( path, flags=IO::RDONLY, mode=0660 ) @driver.open( nil, path, flags, mode ) end --- I''m guessing it''s that first nil there, but I''m having some trouble figuring out what''s going on. Jake Jeremy McAnally wrote:> You didn''t really give us the error...just the stack trace. :) Can > you tell us exactly what exception is being thrown? > > --Jeremy > > On 2/13/07, Jake Janovetz <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> c:/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/debug.rb:121:in >> `put_file'' >> Jake >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> > >> > > > -- > http://www.jeremymcanally.com/ > > My free Ruby e-book: > http://www.humblelittlerubybook.com/book/ > > My blogs: > http://www.mrneighborly.com/ > http://www.rubyinpractice.com/-- 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 -~----------~----~----~----~------~----~------~--~---