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 HERE
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:
$ ruby ./Desktop/gen_encpolygons.rb
./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'
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:
The error tells you that the call in line 11 is wrong. In the code, it attempts to pass in 4 arguments, but the actual function requires no argument. You need to check on that line. Also, it seems that the line is calling line 95 in the code. I am guessing that line 95 is the function prototype (def ....) which should tell you exactly how the function should be called.
OK... Just downloaded the code and look at it. The error in line 95 occurs because it call the function generate_js_border_overlay. Then, the problem is actually from line 11 where it attempts to create mysql using mysql module. Do you have module mysql installed? The one under ruby library folder.
When ruby creates a definition, it also expect the same number of argument passing to the function. If it mismatches the number, ArgumentError exception will be thrown.
Using irb won't help in this case because you need 3 modules - rubygems, mysql, and geo_ruby. If you have them, try to type require 'mysql' in the irb to see if you have the gem installed correctly. By the way, do you have all those gems? Try 'gem -v' to see if you have ruby gem installed. Then try 'gem list --local' to see what you have. In your gem, you must have both mysql and geo_ruby gems.
I have gems installed.
...among all the others.
MWmbPro:~ Wolfemac$ gem -v
I believe I have everything installed correctly, and everything should be set up to run correctly through MAMP.
Is there anyway I can check to make sure something isn't messed up on the install? I can't see any problems with the code, so I assume it must be something wrong with my ruby install - although that all seems to be working properly as well.
Hmm... I don't have the access to the code I have coded in Ruby that use another type of database connection class... Then you could hack the code and change it to another database connection class of your choice... Are you in hurry of this? I may not be able to get back until Monday for the code...
Hmm... Do you have the MySQL server installed? You still need the real MySQL in your computer. Only gems won't actually work. Here is the API of the MySQL your script may need. I used it to do the work for storing certain stuff I search from the Internet to the database for me. I remember that using MySQL::new created certain problem and people would not use it anymore. The script you gave looks out-dated too. :(
I hope you get it to work. I just checked my Linux box and it doesn't have mysql gem in it; however, I can still use 'require mysql'. Yet, you may not need to uninstall the gem but rather install the MySQL to your computer. :)
If the installation includes the MySQL libraries that ruby is looking for, it should be able to find it. I am guessing that the way MAMP installs the MySQL is not the way ruby can see the library. You may try to reinstall MySQL and see how it work? :)