Hi all
Hoping someone could tell me the answer to the following.
I have a class defined in a file: TestWebsite. The main program requires the 'net/http' library and also the TestWebsite file. The class "TestWebsite" contains several class methods that use things such as "Net::HTTP.get_response()" however I get the following errors:
/net/http.rb:380:in `get_response': undefined method `request_uri' for #<URI::Generic:0x2d3b9c URL:example.com> (NoMethodError)
from /opt/local/lib/ruby/1.8/net/http.rb:543:in `start'
from /opt/local/lib/ruby/1.8/net/http.rb:379:in `get_response'
from ./test_website.rb:10:in `test'
It's my guess the the class methods aren't able to access the net/http library which is in the kernel namespace, if this is true then what must I do to allow them access?
Many thanks,
Gabriel
Are you using a complete URI or just part of one? For example,
'domain.com' is not a URI. Further:
[root@server15 mwhite]# ruby -r uri -e 'p
URI.parse("google.com").host'
nil
[root@server15 mwhite]# ruby -r uri -e 'p URI.parse("http://
google.com").host'
"google.com"
If that's not the problem, maybe you could give us some code? Good
luck!
Matt
···
On Oct 1, 8:35 am, Gabriel Dragffy <g...@dragffy.com> wrote:
Hi all
Hoping someone could tell me the answer to the following.
I have a class defined in a file: TestWebsite. The main program
requires the 'net/http' library and also the TestWebsite file. The
class "TestWebsite" contains several class methods that use things
such as "Net::HTTP.get_response()" however I get the following errors:
/net/http.rb:380:in `get_response': undefined method `request_uri'
for #<URI::Generic:0x2d3b9c URL:example.com> (NoMethodError)
from /opt/local/lib/ruby/1.8/net/http.rb:543:in `start'
from /opt/local/lib/ruby/1.8/net/http.rb:379:in `get_response'
from ./test_website.rb:10:in `test'
It's my guess the the class methods aren't able to access the net/
http library which is in the kernel namespace, if this is true then
what must I do to allow them access?
Many thanks,
Gabriel
Oh thank you so much, you spotted that one a million miles off, I missed out the http://. Have corrected this but now getting errors like:
./test_website.rb:13:in `test': uninitialized constant TestWebsite::NET (NameError)
MMM something to keep my mind ticking over.
Many thanks
Gabriel
···
On 1 Oct 2007, at 16:10, Matt White wrote:
Are you using a complete URI or just part of one? For example,
'domain.com' is not a URI. Further:
[root@server15 mwhite]# ruby -r uri -e 'p
URI.parse("google.com").host'
nil
[root@server15 mwhite]# ruby -r uri -e 'p URI.parse("http://
google.com").host'
"google.com"
If that's not the problem, maybe you could give us some code? Good
luck!
No problem. If you need more help, be sure to give us the code that is
causing the error and not just the error.
···
On Oct 1, 9:50 am, Gabriel Dragffy <g...@dragffy.com> wrote:
On 1 Oct 2007, at 16:10, Matt White wrote:
> Are you using a complete URI or just part of one? For example,
> 'domain.com' is not a URI. Further:
> [root@server15 mwhite]# ruby -r uri -e 'p
> URI.parse("google.com").host'
> nil
> [root@server15 mwhite]# ruby -r uri -e 'p URI.parse("http://
> google.com").host'
> "google.com"
> If that's not the problem, maybe you could give us some code? Good
> luck!
Oh thank you so much, you spotted that one a million miles off, I
missed out the http://. Have corrected this but now getting errors like:
/test_website.rb:13:in `test': uninitialized constant
TestWebsite::NET (NameError)
MMM something to keep my mind ticking over.
Many thanks
Gabriel
You can force constants to be evaluated from the
top-level rather than from the current lexical scope by
prefixing the constant with '::'
class TestSuite
ok = ::Net::HTTPOK
end
Gary Wright
···
On Oct 1, 2007, at 11:50 AM, Gabriel Dragffy wrote:
Oh thank you so much, you spotted that one a million miles off, I missed out the http://. Have corrected this but now getting errors like:
./test_website.rb:13:in `test': uninitialized constant TestWebsite::NET (NameError)
MMM something to keep my mind ticking over.