Saturday, January 05, 2008

Ruby Obsession - Day 2 or 3

I write day 2 0r 3 because I am writing this post at 6 AM of day 3, after spending yesterday wading through the pile of obstacles that came with working through the tutorial in my latest Ruby book. Egad, this language and it's toolset change so fast the texts can't begin to keep up.

But, I got past it, at least the first bug, and am now forging on through the rest of the book with my scabbed together version of the application they are building. All the while realizing that I am quite a ways past what they are doing now but that somehow this time it is sinking in even more. Jeez, 43 years old and it's like I'm back in the computer labs. This time I'll pay attention.

So, I'll just walk through the problem, specifically, and link to those places that helped get me through it. The text Agile Web Development with Rails has the usual message boards support forum, with people patrolling them closely enough that I got responses within minutes of posting. Behind Rails, there is a real, energetic community, it's infectious.
the problem:
#1 - In seemingly every book and text, they glaze over MySQL handling, usually telling you to go to a MySQL tutorial to learn how to write this single line of code, but carrying on as if you know what they are doing without explaining it specifically. Me, sometimes I'm really dumb, I need it down to the nuts and bolts. I understand there are all kinds of SQL tutorials and books, I just want to know what to type in now.

the setup:
In starting every rails app, you have to set up a MySQL Database. Using instant rails, there are a lot of tools automatically set up for it. MySQL is installed and you can get a mysql> command line simply by typing:
(dos command line in directory of new rails app-arbitrary before the >)
..\instantrails\work\depot>mysql -u root (and hit enter)
(this all works because in my desktop HD I have SQL set up as root user with no password.) Also important is to go to the config\database.yml file and set it up like this:
development: adapter: mysql database: depot_development username: root password: timeout: 5000

One other thing, from a different tutorial, and maybe not important. There was a fix on Curt Hibbs' tutorial Ruby with Rails revisited, for MySQL, which I did and seemed to allow privileges. Now, I went back many times and redid everything, and the last couple of times I did not need to do it, but that might be MySQL storing this command whether I wiped the DB out or not. So if you are having a problem getting MySQL to recognize your migration, try entering this from your nice command line:
grant all on depot_development.* to 'ODBC'@'localhost';
Someday, I promise I will learn exactly why that matters, or doesn't matter, but for the time being, it worked, and time spent in college computer labs making Assembler, Cobol, and C programs made me superstitious about such things.

Then, go ahead and create or drop your MySQL DB's from the command line like this:
(this is the mysql command line embedded in the DOS command window)
mysql>create database depot_development;<

This is scattered all over the place I know, but that seems to be the norm. I had to be explained this myself by someone on the message boards, here's the link.

Also, if you're coming here for advice on the tutorials, do this tutorial first, before all others, the more I do the more I realize that this is the best: Rolling with Ruby on Rails Revisited

Soon, maybe today, I will compile and tackle the entire problem of working around the scaffolding in the text. There are many helpers and many bread crumbs to follow, the message boards did it for me, but I want it to be easier for the next guy.

No comments: