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.

Thursday, January 03, 2008

Ruby for Rails - A new start

As usual, let me make my usual disclaimer, I realize nobody is reading this, but I AM writing it.

Meta4worldz, from the main site, which has simply been some baby pictures and some stories for over a year now, all of my blogs (meta4worlds - fiction site , Cubs Obsession , Bears Obsession , and even Mollyworldz, will be changing. All of them will be re-developed, along with at least one other site that I plan to devote to Programming.

Over a year ago, I learned about a different programming language, Ruby, and it's supposedly revolutionary deployment, Ruby on Rails, Rails being an application framework written by David Heinemeier Hanson. The framework, as well as the Ruby language and compilers, are all Open Source and all free. And they work very nicely. All of this has been said, and even demonstrated, in this video, about which much hyperbole has been written already, and somewhat rightly so.

When I first watched the video, it was like sitting over someone's shoulders and watching them work a computer, some tech who knew way more than I did, and so fast that it was hard to process what he was actually doing. Still, it caught my attention, and in my spare time since then, I have gotten to the point of understanding exactly what he did, and appreciate how simple it was and how simple it could be for even me. One thing I realized early on was that here was finally a new branch of programming development that I could sink my teeth into and go.

So, one year later, around a full time job and a now one year old child, I'm ready to do this thing, because there is still room for someone to spread the word of Ruby on Rails, teach it, and deploy it in new and exciting ways. As it is with almost every programming style and language, the tutorials available and even text material are spotty at best, cluttered with mistakes, or possibly just oversights, in them.

One set of tutorials I can recommend whole-heartedly, doing what the video does as far as exciting you about this language, but with actual coding and installation instructions that work is the ON LAMP tutorials by Curtis Hibbs, another name that will constantly come up as you venture into Ruby on Rails, and kudos to him because he took the time to do it right. It is called Rolling with Ruby on Rails Revisited which is an update to an earlier tutorial that takes you through a simple Cookbook program. If you just want to see if you like this whole RUby on Rails thing, Do this tutorial, maybe the only problem with it is that by trying to write loosely and set in as a workplace scenario, his prose gets a little weary, but just a little. It doesn't take long and when you're done there is something that you can look at at realize the potential of it all.

As far as my own tutorials, every day there will be Ruby news from me, book reviews, tutorials, either mine or a pointer to someone else if they put up a good one, there are a few, each with their own merits, and commentary as I get along. I've accumulated is a pile of information and thoughts about it all to keep writing posts for quite a while.

For now, I'll get back at it, learning Ruby on Rails that is.

Tuesday, January 01, 2008

Happy New Years, even for you Smokers

Smokers, why should I feel bad for them?In Illinois, January 1, 2008 is No Smoke day. I was actually against this ban at first, but in the year and a half since my own hometown passed local laws prohibiting smoking, first in restaurants, then in bars, I've changed my outlook on the whole concept.

The Illinois Senate, unable to hammer out trivial things like budgets, found their time better spent railroading through lifestyle legislation. That's what I call laws like this No Smoking ban,
lifestyle legislation. Similarly with helmet laws and seatbelt laws. Our downstate legislators thought that by passing laws to tell us how to live, they could act as if they had done something for the people instead of for their small band of wealthy constituents.

I am not a smoker, have never been a smoker, but my parents both smoked, and I have many friends that smoke. I've spent most of my life just dealing with the smoke around me in the places I go to socialize, as have we all. It was never a big deal with me but I won't miss it.

What's amazing are the reactions from smokers. You would think we were jailing them, and having a contrast of towns and establishments just for this last few months has made me glad that the laws were passed, because smokers turned into a whole society of rude whiners. I would hope that a few sessions of standing in the cold would make someone rethink what they are doing, and if they have to do it that bad, why? Already, virtually every workplace has smoking bans, in the local hospital, they can't even smoke outside.

In the town where it was passed early, people complained and said they going to the other town so they could smoke, and came back after a few days realizing there was a reason they didn't go there before. In the town where they could smoke, every smoker blew out smoke at an unprecedented rate, like it was fresh air and they would damn anyone wanting to take the right away from them. It was worse than ever before, and I quit having breakfast at a restaurant there because of it.

It has occurred to me before that it would be funny to drive around and take pictures of people outside "enjoying" a smoke, and posting them. I'll probably do this now, driving to the town of old-timers who actually blew smoke at our table when we had lunch there lasy tear, with my infant daughter. Any other time, this would have been rude, but because they were being oppressed, the asshole that seemed to breathe nothing but smoke just kept puffing. That's another reason I feel no pity for them. If you have to smoke that badly in Illinois, you can go to the private clubs, which is why my American Legion membership is lapsed. It was bad before, now, no way.

I've written my own commentary on smoking many times before, and never posted it, so I'll post this early on New Years Day and go from there.

Happy New Year.