Bucktown Restaurants

For a list of Bucktown Restaurants, go over to http://cornerlens.com/chicago/bucktown/.  I’m slowly compiling a list of them.  Thanks.

Third place to go

Thank God Starbucks created a third place to go. First two being home and work. It is easier to code/study when there’s noise in the background and other people also slaving away. At least for me. Although, I’m at Caribou, not Starbucks.

Checklist for a new Rails project

Here’s a cheat sheet to starting a new rails project.

  1. Create the rails proj (rails proj_name)
  2. Update the database connection (config\database.yml)
  3. Create the database (create database)
  4. Generate the model (ruby script\generate model)
  5. Edit the migration file (db\migrate\…)
  6. Create database table for the model (db\migrate\rake migrate)
  7. Generate the scaffold (ruby script\generate model controller)
  8. Run the server (ruby script\server)
  9. Run the app (http://localhost:3000/controller)
  10. Eat the cake

Welcome 2007!

Happy 2007!  Let the coding fun begin.

Where is the ChicagoDevHouse?

I just ran across this group called “SuperHappyDevHouse“. It is a Bay Area get-together for geeks to collaborate and code all night long. I would prefer a group that meets every night in a coffee shop and code away. I don’t expect everybody to show up every night, but it would be nice to always have someone to code next to.

Controllers and layouts

Every controller has its corresponding layout with the same name. To have a consistent look in an application, every controller should use the same layout. To do this, in the controller you can set the layout by using the following line:

layout "<global_layout>"

ElementNode.setAttribute(name, value)

I have to make an html table sortable by any column. I found the following javascript library that does the trick: “sorttable: make all your tables sortable

There is one problem: my table has alternating colors for the rows. After the sort, some adjacent rows have the same color.

Solution: After the sort, set the color to alternating colors.

var sortedRows = document.getElementsByTagName(“tr”);
for (var i=0; i<sortedRows.length; i++) {
    if (i%2) { sortedRows[i].setAttribute(“bgcolor”, “white”); }
    else { sortedRows[i].setAttribute(“bgcolor”, “silver”); }
}

Cheaper than Netflix

In between browsing the web, learning ruby and ruby on rails, I need to keep myself entertained. I borrowed a number of items from Alexander’s huge DVD collection. I wrote down the list so that I would not forget: http://www.beenote.com/user/odie/tag/show/101

Generate a model then a scaffold

To start a rails project, I would suggest generating a model, then generating a scaffold.

% ruby script/generate model
– creates a migration file; edit the migration file to create the db table for your model
– % rake migrate
—- to create the db table using the migration file

% ruby script/generate scaffold
– creates the layout and the scaffold stylesheet

Eclipse, RDT and RadRails

I am tired of having multiple DOS windows and wordpad editors open all at the same time to work on my ruby on rails project. So I decided to download the Eclipse SDK, and the RDT (RubyEclipse Development) and RadRails plug-ins.

Installation:
1. Download Eclipse SDK and unzip into a directory.
2. Run Eclipse and use the update manager to install the plug-ins.
a. Go to Help -> Software Updates -> Find and Install …
b. Add the sites for the RDT and RadRails plug-ins (as listed in RadRails Update Sites)
i. RDT: http://updatesite.rubypeople.org/release
ii. RadRails: http://radrails.sourceforge.net/update

To use (with existing project):
1. Run Eclipse
2. Set the workspace to the parent directory of the Ruby on Rails project
3. Create a project file
a. File -> New -> Project -> Rails Project
b. Set the project name to the Ruby on Rails project directory

Links:
Eclipse SDK, http://www.eclipse.org/downloads
RDT – Ruby Eclipse Development, http://rubyeclipse.mktec.com/cgi-bin/trac.py/wiki
RadRails, http://www.radrails.org