Archive for January, 2007

Microsoft Launch Event – SF

January 30th, 2007

Today I had the pleasure of attending the Microsoft launch event for Vista & Office 2k7. While many Rubyists are not big fans of Microsoft, I have nothing against them at all. Not to mention the prospect of getting a copy of Office 2007 for free to go hear some propaganda seemed like a good trade off to me. Seeing as we are considering an upgrade of Office inside in work, I was also able to justify this as a business event.

There are a lot of reviews and comments out there about Vista and Office, so rather than run the full gamut, I would like to highlight a few of the features demoed that caught my eye:

For network file operations, Vista analyzes the current load and changes the network window on the fly. A file that took about 5 minutes to copy from a slow network connection from Vista to Windows XP, took about 1.5 minutes between two Vista computers.

Deployment of new Windows installations (XP or Vista) are much easier with the new BDD tool and Windows PE. BDD allows for easy managing of installation images. Windows PE allows for loading windows drivers, turning the installation into a GUI based process.

Visio 2007 comes with some really nice integration options with various data stores, allowing for complex dynamic visualization tools to be created and managed with limited effort.

Powershell on Vista Enterprise allows for full on Unix like automation scripting. This will really help take the effort out of daily maintenance tasks especially when combined with powerful scripting languages like Perl & Ruby along with access to .NET objects. (’bout time!!)

(And for giggles, this post was made using the new blog features in Word 2007. Looks like the category flags are broken however, oh well).

Tags: ,
Posted in Uncategorized | Comments (2)

Portland

January 28th, 2007

Coming to Portland is always a good time. It’s almost always very laid back and we get to spend time with two very close friends of ours. We came up Friday night and head back to the bay this evening.

Yesterday we went out to “the gorge” I believe officially called Multnomah Falls. It was amazingly beautiful. The pool below was suround with huge snow drifts which spiked up toward the water. I love watching the patterns of the water sprays that separate from the main fall, each spray following the pattern of the one before it with a slight variation.

Hoping to get pictures up in the next couple days, which means I’ll have to look for a good gallery/flickr plugin for Wordpress.

Tags: ,
Posted in general | Comments (0)

Rails Cookbook

January 25th, 2007

Rails Cookbook (bookcover)
A couple of weeks ago I picked up a “Rough Cuts” version of the Rails Cookbook by Rob Orsini. This is the same book that was recently highlighted on the Ruby on Rails blog.

Almost immediately it started to pay for itself. I had a couple issues where I was trying to get my join model to be a sortable list but only keep track of a records position in the list constrained to one of the foreign keys. Well on page 117 there is a recipe for using acts_as_list that automatically manages the position of record in the model and takes a :scope => :model option to constrain the position field to keep track of a record’s position relative to the foreign key “model_id”. Each new “model_id” would behave as a separate list within the same model.

The recipe’s are logically organized and there are A LOT of them: 15 Chapters (560+ pages) dealing with every aspect of Rails you can imagine. While I prefer the writing style of Chad Fowler’s Rails Recipes a bit more, the sheer wealth of information in this resource can not be understated. And the content spans subjects at various difficulty levels from “I built my whole app using scaffold!” to “I’m getting a free ticket to Railsconf.

Two areas that were extremely helpful were in the areas on Active Record and RESTful resources. Since Active Record is the largest and arguably the most powerful part of rails , it’s really helpful to be able to leverage it’s features whenever possible. As they say, “Convention over configuration!” Also RESTful resources are brand new and as such there is not a lot of information out there to help you know how to best use them, so it is good to find resources that do.

Tags: , , ,
Posted in general | Comments (0)

learning to REST

January 25th, 2007

Last week I got a chance to see Andre Lewis speak at the Silicon Valley Ruby Meetup about RESTful resources. While REST is not a new technology, it was only recently implemented in Rails with the release of 1.2. Anyway, while listening to Andre’s presentation I became intrigued with the idea of using REST in one of my applications. The presentation was quite informative and described a lot of the basics of getting started with RESTful resources. He also talked about nested resources which sparked a question which nobody in the room was sure about: How do you deal with resources that are nested within multiple other resources? Is it possible to do it dynamically?

One of the suggested resources to learn more about REST was Geoffrey Grosenbach’s Peepcode. For those not in the know, Peepcode is a site where Geoffrey releases monthly screencasts covering various topics in Ruby on Rails for the cost of $9 an episode. Considering the length of the episodes (75-85 minutes) its a great deal. Anyway, not to long ago an episode dealing with REST was published. After Andre’s talk I popped over to Peepcode and picked it up. It covered much of what Andre discussed, only in more detail. It also explained that HABTM relationships do not play well with REST, so that means my discrepancy app for work is not a good candidate to refactor for REST. However my recent dj mix project just might be. While the screencast was informative, and encouraged me to purchase other episodes, unfortunately my question posed at the meetup was still not answered.

My quest to have my question answered next took me to the Rails-talk Google group, formerly the Rails mailing list. So far I’ve received one response:

You could have a filter in the books_controller to pick out any author_id, publisher_id, etc. and scope the Book.find(…) according to these params. That should be simple and DRY.

If this is the way to go, then it might do to put together some meta-programming to create some dynamic finder methods so if the resource is nested in another resource later, no additional work would be required to make it functional.

One resource I came across that was very helpful in showing how to use REST in a real world applicaiton was the source code for beast. As I explored the source, I got a much clearer picture of how to properly put together my controllers and models.

REST, depending on what you’re working on, can drastically simplify your code; however it isn’t always appropriate to implement REST in your application. A careful examination of your design will let you know whether simplifying your interface is both possible and preferable.

Well, that’s it for now.

Tags: , , , ,
Posted in general | Comments (2)

:allow_nil in validates_numericality_of

January 18th, 2007

While working on an internal Rails app here at work, I kept encountering an error when trying to submit a form. The form was fairly elaborate containing quite a bit of data using several models. When it came time to submit the form with some dummy data, I kept getting a nil error.

At first I thought something was wrong in my controller. I tried again putting data into every field and the form submitted successfully and data was saved.

Then I thought maybe I had turned nulls off for a field I was asking data for. After going over ever field that was submitted I found nothing. I was stumped. I was having problems saving a form because data was missing, but the model wasn’t putting null constraints on the data before saving it.

Or was it? Finally I looked down at my validation statements of the model being saved. Two fields were set to validates_numericality_of. When I commented these out, the form worked perfectly every time I submitted it. It finally came together. Since the fields in question were optional, and being left blank, the validation was testing whether a NULL value was a number and failing.

Now having identified my problem I had to figure out how to keep my validation without testing NULL values. Well it just so happens that when I looked up this validation type, there was an option to :allow_nil (nil being NULL in Ruby). Popped that bad boy back into the model and everything worked marvelously.

I’ll be off to the local Ruby Meetup pretty soon. It’ll be good times for sure.

Tags: , ,
Posted in general | Comments (0)