Archive for the 'ruby' Category

A great quote and another opportunity to learn

By way of Paul Graham comes this quote by Kenneth Clark. I haven’t found the original source, so if you read this and know it, please add it to the comments. When I read this, I realized this is the guiding principle I’ve used in determining what new things to learn as a programmer:

If a lot of smart people have liked something, you should try and figure out what they saw in it.

This is what led me to Ruby and Rails. It’s what led me to Python and the world of dynamic languages five-plus years ago. It’s what drove the decision to implement Rails in Ruby (if I can speak for DHH for a second).

Today, I’ve found another opportunity to learn something new that a lot of smart people rave about: Structure and Interpretation of Computer Programs (Amazon version, Free HTML version). UC Berkely is offering CS 61A The Structure and Interpretation of Computer Programs as part of their free-to-the-public webcast series of courses.

If you love to learn, it’s a great time to be alive.

Good Week for Rails and AJAX On Safari

I’ve been a Safari technical books service subscriber for over four years now. The service just keeps getting better. But I’m not here to pimp Safari (or pimp Safari) but to point out how good of a week it’s been for Rails developers with a Safari account.

Just this week we’ve gotten a Prototype and Scriptaculous shortcut, Ajax On Rails, Prototype Quick Reference, and an update to the beta version of Rails Cookbook.

Here’s what was already on my bookshelf:

I certainly haven’t read all these titles yet, but you’ll not hear me complaining about a lack of Rails documentation.

File Column Unit Testing

In the Rails app I’m currently working on, I’m using the wonderful file-column plugin and updating one of my model’s position attribute manually using an after_create callback. It’s working out well. How do I know this? I tested it of course!

But, I ran into a little bit of a gotcha in the course of development. In my unit tests for the aforementioned model, I use fixture_file_upload when creating new instances. file-column treats these as it would any other uploaded file, which is exactly what we want for testing, with one exception: it stores the uploaded files in the same directory space regardless of RAILS_ENV. So, if you’ve uploaded some files through your browser as part of development, your unit tests will stomp anything with the same id.

The solution? It’s simple but undocumented, so here goes. file_column takes a couple configuration options. One of these is :root_path. It defaults to File.join(RAILS_ROOT, “public”). So, here’s the code from my model:

file_column :image,
            :root_path => ENV["RAILS_ENV"] == "test" ?
                          File.join(RAILS_ROOT, "public", "test") :
                          File.join(RAILS_ROOT, "public"),
            :magick => {:geometry => "640x480",
                        :versions => {:thumb => "128x96"}}

This puts our test files in public/test and our development files in public. I suppose I could move this functionality over to environments/test.rb, but it seems to make sense in the model for now. Opinions and dissent welcomed.

raleigh.rb moves to Redhat

I’ve been going to raleigh.rb meetings since about the beginning of this calendar year. The meetings were held at a local Panera Bread and a few of us would gather around a table or two and talk about Ruby and Rails. It was evident, even then, that Rails was about to reach the tipping point. Each meeting it seemed like a couple new faces appeared and we started occupying three or four tables.

But the last meeting was just crazy. We took an entire section of Panera with about 30 people. (I took pictures, but they’re stuck on my phone until I get a data cable.) Thankfully Panera was nice enough not to kick us out.

Matthew Bass led us through a recap of RailsConf. After a few RailsConf stories, the discussion veered into all things Rails. More than a handful of people hung out afterwards and talked until the Panera people were basically sweeping up around us. Then we went outside and hung out some more. :) I’m only sorry Nathaniel, who started and organizes this group, wasn’t there to see it.

It’s evident that Panera is no longer a viable venue for raleigh.rb. Thankfully, Redhat has stepped up to the plate and offered their beautiful Raleigh facility for our use. Redhat also donated facilities for BarCampRDU and hosts other local tech-oriented groups. So, many, many thanks to Redhat for supporting the local tech community.

I also just noticed there are now 98(!) members of raleigh.rb. There were about 87 when the July meeting explosion happened, so I wouldn’t be surprised to see 40 or more at the next meetup, especially since the Relevance guys are going to be demoing their hot new Streamlined Rails admin interface. I’m so there.

UPDATE

After jumping through a few hoops, I was able to get photos from my phone without the need for a data cable. Here are two of the three I took. There’s not 30 people in these shots. I couldn’t fit everyone in the frame, and a few people came after these were taken. And, yeah, they were taken into the light. Oh well. If you want to browse the full-res shots, here’s the raleigh.rb gallery I started on smugmug.

raleigh.rb

raleigh.rb