This weekend, while working on upgrading murfie.com to Rails 3, I found a situation requiring url_for()… except, I wasn’t using it with an ActiveRecord model :/

Yehunda Katz and ActiveModel to the rescue! Rails 3’s ActiveModel is a great way to mix ActiveRecord functionality into any object. Yehunda’s article covers validations and serialization, but glosses over ActiveModel::Naming.

class Model
  extend ActiveModel::Naming

  ...other model code...

end

Adding this module to a class means that url_for(Model) just works! Of course you need to have routes setup, but url_for will automatically construct the named routes if they match up with the model name.

Under the hood, rails is calling model_name on the class of the object passed into url_for(). Model.model_name returns a string, but is actually an instance of ActiveModel::Name, which is then used by url_for() to generate the named route for the object.

pry> User.model_name
=> "User"
pry> User.model_name.class
=> ActiveModel::Name

Look at this picture. See where I have circled the unsubscirbe link? Yes, that grey text with no underline is a link. Secha Touch, who sent this email, should be ashamed.

Today I found myself needing to move data between two heroku apps. If you have the pgbackups addon installed, it turns out this is really easy:

heroku pgbackups:restore DATABASE `heroku pgbackups:url --app myapp` --app myapp-staging

Heroku covers the process more in depth in their documentation

Heroku rocks!

Rails Is for Beginners

This morning I came across an article on hacker news titled Rails Is Not For Beginners. The article is actually about Sinatra, but the link-bait title is dead wrong. Rails is perfect for beginners and here is why …

A friend of mine with zero programming experience recently asked me to help him learn web development. We setup rails together, and I pointed him to some online tutorials. When he called me the next evening, he could barely contain his excitement:

“Rails is awesome! I can edit, add, delete! This is a real web app and I made it!”

In Rails, with only a few commands you can have a fully functioning CRUD app built on scaffolding. No experienced Rails developer I know uses scaffolding. So why is it still in the source code? Because Rails is for beginners.

The best way to teach anyone web development is to inspire them to learn on their own. My friend is a long way from being a productive web developer, but because of Rails he is excited to learn more.

If you are a beginner and looking for a place to start, I recommend railstutorial.org. It is a fantastic resource, and best of all the online version is free.

Moving to Octopress

I’m moving the blog from dreamhost+wordpress to heroku+octopress (which is built on jekyll). Anything before this point in the blog has been imported and might be a little off. You have been warned!

Last Friday, I did a radio interview on 1670 AM for my startup - GeoHuddle.  The full audio is available here:

[wpaudio url=”http://www.southpolesteve.com/wp- content/uploads/GH_interview.mp3” text=”InBusiness with Jody and Joan - Interview with Steve Faulkner”]

Just click the little play button to listen

Total Distance: 92.58 miles Max Speed: 14.7 mph Average Speed: 4.75 mph

Click on the picture for a bigger version

Practicing Landings

Can’t help but post about this again. GPS tracking for sailing is pretty awesome! Today I sailed 25 total miles and had a max speed of almost 10 mph. Thats pretty quick for a sailboat. Also, I did a bunch of practice landings while under sail. You can see on the map below how I kept circling around and landing at the pier and a pin in the mooring field. At the end of the season I think I’ll do a big summary that gives all kinds of interesting statistics about my sailing this summer.

View Sailing Summer 2010 in a larger map

Copyright © 2012 - Steve Faulkner