Well, the past month has been busy:
Got a new job @ Digital Fountain
I’m really excited about the work environment and the opportunity to learn a great deal from my new boss. I’ll be working across the street from BART, in the same parking lot as my gym! It’s also only a couple blocks from where I used to work, so I’ll be able to meet up with friends and I already know where all the good places to eat are!
Got our business license for my wife and I’s consulting company(finally)
While I will be working for digital fountain, we will be growing our design & development consulting company. We just finalized on the logo, so first comes the stationary, then comes the website. This blog will probably move to a more appropriate personal domain (alla blog.markcarey.org or something).
Been working on bringing a client’s site live
I’ve inherited a lot of ugly code, but things are moving along smoothly. Even though the site is in php, I found a way to leverage ruby for administrative scripts and am exploring capistrano for automated deployment of site updates.
Working on my Senior Thesis (almost done)
Well… I walked a month ago in cap & gown, but this stupid thesis is driving me up the wall. I’m almost there. Hopefully I’ll have it done within the week.
Getting my studio back in tip top shape
Who knew that the Evolution UC-33e didn’t need a power supply to work if plugged in via USB. I’ve had that stupid thing sitting on the shelf doing nothing for the past 2 years, thinking I had lost the power supply. I went to look only to find a replacement unit only to find out it was optional!!
Also I upgraded from Finalscratch2 to Traktor Scratch. I was tempted to go with Serato Scratch, but the Traktor Software is just so much better. Hopefully now that the hardware is made by the same company as the software, the platform will stabilize. I’ve got Ableton Live and have been tempted to start using it for doing more creative mixes, but the setup takes a lot more work to get to place where you can have fun with it. With Traktor Scratch I just cue an mp3 track to a turntable and rock out. Besides, there is just something about having a vinyl record under your fingers that feels so right. I should have a new mix online very soon as well (after the paper is finished).
Tags: ableton, ableton live, dj mix, finalscratch, music, music production, ruby
Posted in general | Comments (0)

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: books, coding, ruby, Ruby On Rails
Posted in general | Comments (0)
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: coding, habtm, REST, ruby, Ruby On Rails
Posted in general | Comments (2)
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: ruby, Ruby On Rails, validation
Posted in general | Comments (0)
Well the latest release of Ruby on Rails has finally been released and the gems have been pushed to rubyforge.org. For those of you wanting update your gems run:
gem update rails ––include-dependencies
If you have any current projects you are working on, you will need to update them. First, change your config/environment.rb file so that your Gem version is 1.2.1 (on mine it was line 8):
RAILS_GEM_VERSION = ‘1.2.1′
Then run this from the root of your project:
rake rails:update
Also if you are updating and have a previous version of rails frozen in your vendor directory (ie- if you downloaded the source to the vendor directory as described in the recently released 2nd Ed. of AWDwR), then you will need to delete that directory from there (re-freezing the new Rails if necessary).
Tags: ruby, Ruby On Rails
Posted in general | Comments (2)