Thursday, 20 July 2006

Using Names in Rails Routes Instead of IDs

I spent tonight cranking through some Ruby on Rails has_many :through association oddities and after pounding my head against the keyboard, I decided to shift gears and figure out Ruby On Rails Routes.

By default, the Rails expects ID to be passed in URL strings. But that’s really lame, and passing words is much cooler so, how do you do that?

Turns out, it’s so simple no one talks about it (vs. so hard no one’s figured it out).

Take the following example:
http://mydomain/friend/show/1

What’s ‘show’? Who’s friend 1? Don’t they have a name?
Sure they do. Let’s say their name is ‘Wooster’

Here’s how to make turn the above url string into:
http://mydomain/friend/wooster

  1. Get the name of the database column storing your friends’ names (let’s say it’s ‘name’).
  2. In config/routes.rb add, somewhere above the default route:
    map.connect 'friend/:name', :controller => 'friends', :action => 'show'
  3. Now, in friends_controller, find def show and change it to:
    @friend = Friend.find_by_name(params[:name])
  4. Lastly, all the id-based urls pointing to our good friend Wooster need to be updated to reflect the name-based change. Like the one your Friends list.rhtml file.
    'show', :name => friend.name

Wednesday, 19 July 2006

Tuesday, 18 July 2006

When Murphy Decides You Need to Use Windows

Just last week, I was taking with someone about Parallels Desktop. Cavalierly, I stated how I grabbed a trial key – but then realized I had no need to use for Windows.

Then just days later, I needed to see what a process looked like on Windows. Funny, Murphy, real funny.

Option 1. The Mac mini home server does have a Windows partition on it, but no monitor. So I’d have to disconnect it form the rats nest of external hard drives and other peripherals, plug it into the living room TV and reboot.

Option 2. Install VirtualPC on the eMac with the dead keyboard (no ability to open the DVD drive). Share the install disc across the network and run the install via VNC.

Monday, 17 July 2006

T-75 and Counting

PodcastNYC lists out 9 Ways to Kill Podcasting. Articulating some of the ‘this feels wrong’ parts of the iTunes, Yahoo podcast directories.

On the other side, thanks to Dave Winer for comparing the river-of-news vs. portal presentations. Personally, I see time-based navigation as a good way to see how a story evolves – though, I think the story itself should be the primary navigation method.

Any individual item in an rss feed has a number of attributes. From my perspective pubDate, source and author are of secondary to title, link, description.

Oh, and if your interested in getting early previews of this project – drop me an email.

Friday, 14 July 2006

“If It’s in iCal, It’s Real”

Part of yesterday’s desk cleaning was taking a critical look at my Thing To Do stickie and committing to trimming it down. All the To Do List things I’ve looked at are independent of calendar – aside from some vague notion of deadline.

A while back in scheduling a conversation with Dave Slusher, he said;

“If it’s in iCal, it’s real.”

So, I’m migrating all my existing ToDo to actual, slots on the calendar. New things will go straight to the calendar. This should end the ‘what should I focus on now’ question.

Thursday, 13 July 2006

Shrug The Movie

Thanks to Tyler Cowen for passing along word of Atlas Shrugged the Movie.

Fun Facts from the previous link:

  • First draft of Part 1’s (of 3 ??!!) script completed and rated 8/10 in ‘philosophical fidelity to the novel’.
  • Angelina Jolie is interested in playing, “the greatest female character in all of literature”, Dagny Taggert.
  • “…everybody has been waiting breathlessly for an Atlas Shrugged movie since 1973…”

All this brings up a good question – did I even finish the book? Hmmm. I’m pretty sure I read the last chapter.

T-80 and Counting

Hit a fairly big roadblock today. I’m sure there’s a number of workarounds. I’m guessing this difficulty is a hint that I need to think about the mechanics of the project differently. I very well could be building it the hard way – and the roadblock is telling me that.

Wednesday, 12 July 2006

Katie Couric Steals Bloggers Pen

“They pulled me out of the auditorium and told me that they’d become aware of the fact that I had a blog, they said, ‘We don’t want you to participate.'”

Wow.

Big Media just keeps giving us reasons to ignore them.

UPDATE: and, according to this New York Times article on the event, we are ignoring them quite happily:

“… few people thought they could find a way to be home at 5:30 in the evening…”

More at MNSpeak.