Saturday, April 16, 2011

Installing RubyGems with no Rdoc/RI

Finally took the step today of not generating RDoc and Ri when installing Ruby Gems by default by adding the following to ~/.gemrc.

install: --no-rdoc --no-ri
update: --no-rdoc --no-ri

Saturday, April 9, 2011

Code examples from Associative Arrays with James Edward Gray II

I watched David Brady's pod call with James Edward Gray II discussing Associative Arrays. There are definitely some gems (no pun intended) in this video. While watching the video I transcribed the code examples below.

Associative Arrays with James Edward Gray II from David Brady on Vimeo.

Monday, April 4, 2011

Looking for a Montréal-based Ruby on Rails developer?

Admittedly, I have been booked for a while now and haven't had any time to take on any projects. So where does one go if they are looking for Ruby on Rails developers located in Montréal? I would recommend checking out Working with Rails.

You might like to do a keyword search for Montréal or browse for developers located in Canada. I hope this helps your search for developers.

Saturday, April 2, 2011

A script for a Ruby on Rails Blog in 15 minutes

Early in the new year I made the switch to Vim from Textmate. I needed a lot of practice so I replicated the Rails screen-cast for a blog in 15 minutes produced by Ryan Bates over and over again. It was a great way to get familiar with Vim after years of Textmate editing. I wrote up a script based on that screen-cast to aid my practice, and I have also found it useful in quickly demoing Rails to a newbie. The script itself won’t make sense without viewing the screen-cast, but a good reminder of the steps if you find yourself in the same situation.

  • Create a new rails application
  • Start and verify server is running
  • Generate Post (title, body) scaffold
  • Demonstrate adding, updating Posts
  • Add validation rule to Post
  • Demonstrate adding an invalid post
  • Refactor posts/show view into partial
  • Refactor posts/index to use partial
  • Demonstrate in browser
  • Demonstrate XML (curl http://localhost:3000/posts.xml)
  • Add JSON format for Posts
  • Demonstrate JSON (curl http://localhost:3000/posts.json)
  • Add atom format (posts/index.atom.builder)
  • Add auto_discover_link_tag to layout
  • Add basic authentication to PostsController
  • Demonstrate in browser
  • Add Comment scaffold (body)
  • Don’t forget to update routes
  • Demonstrate routes (rake route)
  • Add list of comments to posts/show
  • Create comments partial
  • Add comments form to posts/show
  • Clear out CommentsController
  • Add create action (but use #build instead of #create!)
  • Create does not save, show off debugger
  • Demonstrating save comment in debugger
  • Change build method to #create!
  • Update comments form to use AJAX
  • Update comments controller to use AJAX
  • Demonstrate fall back without Javascript enabled
  • Create automated test for posting comments
  • Review with broken test
  • Review console by updating a post title, add comment

Here are the various 15 minute blog screen-casts for the different versions of Rails:

Friday, April 1, 2011

Rails server hangs on startup with Dalli Gem and Memcached

If your using Dalli and Memcached, ensure you are running the latest version of Memcached (at least 1.4 or greater) otherwise when starting Rails, the server will hang. You can upgrade Memcached easily enough with MacPorts (if that's what you're using):

sudo port upgrade memcached

If you haven't installed memached using MacPorts before and just have the version shipped on OSX, then do an install:

sudo port install memcached


Please note this blog is no longer maintained. Please visit CivilCode Inc - Custom Software Development.