(ArgumentError) - in `initialize': wrong number of arguments (4 for0)

M

Micah Wolfe

Greetings all,

Please forgive the double posting, I just thought it would be better to
list this issue separately, with a more communicative subject (please
reply to this one).

I've just started learning Ruby (and Geo Ruby), and am trying to create
overlays for Google Maps.

I found a [seemingly] great tutorial for doing this @
http://blog.newsplore.com/2009/02/22/spincloud-lab...

...and it uses Ruby - cool, eh?

Have everything installed properly (as far as I
can tell - gem list gives me the whole bundle including: mysql (2.8.1)).
MySQL working fine.

I get this error when trying to run the script (attached) from a shell:

Command:
$ ruby ./Desktop/gen_encpolygons.rb

Returns:
/Desktop/gen_encpolygons.rb:11:in `initialize': wrong number of
arguments (4 for 0) (ArgumentError)
from ./Desktop/gen_encpolygons.rb:11:in `new'
from ./Desktop/gen_encpolygons.rb:11:in `generate_js_border_overlay'
from ./Desktop/gen_encpolygons.rb:95

I've googled extensively for similar argument errors, and I'm not
finding any good matches (or solutions).

...so I opened an irb session to try a little test:

Command:
Mysql::new('localhost', 'root', '', 'my_database')

Returns:
NameError: uninitialized constant Mysql
from (irb):1

Then I checked for the gem:=> true

Any help is greatly appreciated.

Best,
Micah

Attachments:
http://www.ruby-forum.com/attachment/6002/gen_encpolygons.rb
 
M

Micah Wolfe

Greetings,

Does anyone have any ideas about this? I am still stuck.

Thanks,
Micah
 
H

Hassan Schroeder

Does anyone have any ideas about this? I am still stuck.

About "this"? It's a popular (or at least widely-used) four-letter English
word, though the exact meaning is pretty context-dependent.

HTH!
 
Q

Quintus

Am 11.03.2011 20:53, schrieb Hassan Schroeder:
About "this"? It's a popular (or at least widely-used) four-letter English
word, though the exact meaning is pretty context-dependent.

HTH!

Maybe he comes from another language and means the "self" keyword?

Vale,
Marvin
 
M

Micah Wolfe

Andrew Wagner wrote in post #986975:
I think it's more likely he meant to put this question on the other
thread
he started recently, which you can find
here<http://www.ruby-forum.com/topic/1226240#new>
.

Yeah, sorry about that. I don't know what happened.

I just wish I could get as many helpful replies as I received to the
mis-post.

Additional info (eratta):
System info:
MacBook Pro
OS X 10.5.8
2.6 GHz Intel Core 2 Duo
MAMP v. 1.9.4

irb:=> true

I have gems v1.3.6 installed.
mysql (2.8.1)
GeoRuby (1.3.4)

Best,
Micah
 
H

Hassan Schroeder

What happens if you run the snippet below as a standalone script?

# start snippet
require 'rubygems'
require 'mysql'

puts "checking -- #{Mysql.class.name}"
borderDB = Mysql::new('localhost', 'root', '', 'test')
puts "checking -- #{borderDB.class.name}"
# end snippet
 
M

Micah Wolfe

Hassan Schroeder wrote in post #987216:
What happens if you run the snippet below as a standalone script?

# start snippet
require 'rubygems'
require 'mysql'

puts "checking -- #{Mysql.class.name}"
borderDB = Mysql::new('localhost', 'root', '', 'test')
puts "checking -- #{borderDB.class.name}"
# end snippet


Hi Hassan,

Thanks for the reply.

I get this:
checking -- Class
/Desktop/test.rb:5:in `initialize': wrong number of arguments (4 for 0)
(ArgumentError)
from ./Desktop/test.rb:5:in `new'
from ./Desktop/test.rb:5

I don't think this is a script problem, but everything seems to check
out with the MySQL, and the other gems.

See why I'm tearing my hair out?

Thank you again for the reply.

Best,
Micah
 
H

Hassan Schroeder

I don't think this is a script problem, but everything seems to check
out with the MySQL, and the other gems.

If a simple Mysql.new fails, I'd be real tempted to delete that gem and
reinstall. Have you possibly done an OS upgrade since you originally
installed it? Or switched to rvm?
 
B

Brian Candler

Micah Wolfe wrote in post #987225:
Hi Hassan,

Thanks for the reply.

I get this:
checking -- Class
./Desktop/test.rb:5:in `initialize': wrong number of arguments (4 for 0)
(ArgumentError)
from ./Desktop/test.rb:5:in `new'
from ./Desktop/test.rb:5

I don't think this is a script problem, but everything seems to check
out with the MySQL, and the other gems.

You don't happen to have a file called "mysql.rb" in your working
directory do you?

I made that mistake before - for example, writing a test program for
sinatra and deciding to call it 'sinatra.rb' :)
 
M

Micah Wolfe

Brian Candler wrote in post #987315:
You don't happen to have a file called "mysql.rb" in your working
directory do you?

I made that mistake before - for example, writing a test program for
sinatra and deciding to call it 'sinatra.rb' :)

Hi Brian,

Thanks for the response.

No, I only have the ruby gem 'mysql.rb' with that name.
If a simple Mysql.new fails, I'd be real tempted to delete that gem and
reinstall. Have you possibly done an OS upgrade since you originally
installed it? Or switched to rvm?

Hi Hassan,

Thanks for bearing with me on this.

No OS upgrade, haven't switched, not using the version manager (should I
be?).

I changed line 11 to borderDB = Mysql.real_connect('localhost', 'root',
'root', 'my_database')

and now I get the following error:
/Desktop/gen_encpolygons.rb:11:in `generate_js_border_overlay':
undefined method `real_connect' for Mysql:Class (NoMethodError)
from ./Desktop/gen_encpolygons.rb:95

Yes, mysql.new failed.

So, I think I am going to uninstall the gem, and reinstall it. Would it
be better to use the 'pure ruby' gem? What would you guys recommend?

Best,
Micah
 
H

Hassan Schroeder

No OS upgrade, haven't switched, not using the version manager (should I
be?).

It's useful, but I wouldn't necessarily start until you figure this out.
So, I think I am going to uninstall the gem, and reinstall it. Would it
be better to use the 'pure ruby' gem?

I would just go with a complete reinstall of the standard gem (with the
native extensions) and see what happens. Document the entire -- i.e.
both removal and re-installation -- process just in case :)

Non-ruby-related tip: use the `script` command to capture all of the
relevant console input and output, e.g.

18:21 ~ $ script /tmp/save-what-i-did
Script started, output file is /tmp/save-what-i-did
18:21 ~ $ pwd
/Users/hassan
18:21 ~ $ exit

Script done, output file is /tmp/save-what-i-did
18:21 ~ $ cat /tmp/save-what-i-did
Script started on Mon Mar 14 18:21:33 2011
18:21 ~ $ pwd
/Users/hassan
18:21 ~ $ exit

Script done on Mon Mar 14 18:21:55 2011
18:22 ~ $

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top