Episode 17: HABTM Checkboxes

Posted over 7 years back at Railscasts

It is often asked: how do I create a list of checkboxes for managing a HABTM association? Ask no more because this episode will show you how to do exactly that.

Productivity Enhancers

Posted over 7 years back at work.rowanhick.com

Tannoy nearfield active monitors. Let's face it churning through documentation or code, can sometimes be mind numbing, no matter how much delegation you do you still have to deal with it and the only way to keep your mind in check, and sometimes to speed things along is to be bathed in your favourite music. Now I have a penchant for all things musical, whilst I don't spend 40k on audio gear at home, I also can't stomach the $50 computer speakers. A previous fan of Klipsch systems I decided it was time to step up the game. Enter these bad boys. "Nearfield active monitors" = speakers designed to be on a studio recording desk, up close to your ears versus across the living room floor. As they're monitors they're designed to be very neutral and flat sounding, allowing the detail of the music to present itself, not be coloured like most residential systems. So you won't have bass or mid range heavy music. To my ears, at low volumes everything is very crisp, tonnes of detail I've picked things I've only heard with Sennheisers on my head. All this comes at a cost, these clock in at $800 retail CAD, before taxes, if you know where to look. However eBay came to the rescue and I found a pair and won the auction for under half that, now they're gracing my desk getting burned in. Nice. (with a capital N). Not Pants.

Productivity enhancers

Posted over 7 years back at work.rowanhick.com

Tannoy nearfield active monitors. Let's face it churning through documentation or code, can sometimes be mind numbing, no matter how much delegation you do you still have to deal with it and the only way to keep your mind in check, and sometimes to speed things along is to be bathed in your favourite music. Now I have a penchant for all things musical, whilst I don't spend 40k on audio gear at home, I also can't stomach the $50 computer speakers. A previous fan of Klipsch systems I decided it was time to step up the game. Enter these bad boys. "Nearfield active monitors" = speakers designed to be on a studio recording desk, up close to your ears versus across the living room floor. As they're monitors they're designed to be very neutral and flat sounding, allowing the detail of the music to present itself, not be coloured like most residential systems. So you won't have bass or mid range heavy music. To my ears, at low volumes everything is very crisp, tonnes of detail I've picked things I've only heard with Sennheisers on my head. All this comes at a cost, these clock in at $800 retail CAD, before taxes, if you know where to look. However eBay came to the rescue and I found a pair and won the auction for under half that, now they're gracing my desk getting burned in. Nice. (with a capital N). Not Pants.

Welcome

Posted over 7 years back at work.rowanhick.com

Welcome to my blog...after many years of reading other's blogs it's about time I gave back nuggets of wisdom. So here it is. I'll keep this bad boy updated on (almost) a daily basis - subscribe to the RSS, sit back and relax...

Paginating Associations

Posted over 7 years back at zerosum dirt(nap) - Home

It’s no real secret that the default Rails pagination helpers are kind of awful. Sure, you can use them, but I wouldn’t recommend it if you expect to scale. Instead, go snag yourself the wonderful paginating_find plugin. And then, if you’re going to be using them with your model associations, whip up an association extension like this:

module PaginationExtension
  def paginate(current = 1, size = 10, options = {})
    options[:page] = {:current => current, :size => size}
    find(:all, options)
  end
end

Now just extend the has_many association on your City class and you can call city.bars.paginate(2) to get the second 10-element page of bars associated with your city.

class City < ActiveRecord::Base
  has_many :bars, :extend => PaginationExtension
end

city.bars.paginate(2)

The good bars are all on the first page though, so consider yourself warned.

RailRoad Class Visualization

Posted over 7 years back at zerosum dirt(nap) - Home

Just saw this InfoQ article about RailRoad and had to check it out. Gotta say, this is by far the best class visualization tool for RoR I’ve seen yet. Set your options, generate those DOT files, and then run them through GraphViz to export your image format of choice. Couldn’t be easier.

Check out some of the examples on the RailRoad RubyForge site, including the diagrams of the popular Depot example app and the much more complex Typo blog package. The latter is a good illustration of why the brief option is provided, heh. If you’re in the UML camp, you might be a little disappointed as the diagrams it produces are closer to BON, but personally I think they’re very straightforward and natural.

Whatever your modeling language preference is, I think we can agree that tools like this go a long way towards legitimizing Rails use in large multi-person projects and are, well, just plain helpful. Big thumbs up.

Welcome

Posted over 7 years back at work.rowanhick.com

Welcome to my blog...after many years of reading other's blogs it's about time I gave back nuggets of wisdom. So here it is. I'll keep this bad boy updated on (almost) a daily basis - subscribe to the RSS, sit back and relax...

Episode 16: Virtual Attributes

Posted over 7 years back at Railscasts

Keep your controllers clean and forms flexible by adding virtual attributes to your model. This very powerful technique allows you to create form fields which may not directly relate to the database.

Episode 15: Fun with Find Conditions

Posted over 7 years back at Railscasts

You can pass more than simple strings to find conditions. Arrays, ranges, and nil values can be passed as well. In this episode you will see the tricks involved with passing these odd objects to find conditions. (Update: audio fixed).

Jack Dorsey and Alex Payne of Twitter - Ruby on Rails Podcast

Posted over 7 years back at Ruby on Rails Podcast

The creator of Twitter talks about developing the popular messaging site.
Also mentioned:

Episode 14: Performing Calculations on Models

Posted over 7 years back at Railscasts

Did you know ActiveRecord provides class methods for performing calculations on models? You can even use these methods through associations.

Go get scope_out - it should be in core!

Posted over 7 years back at The Hobo Blog

The scope_out plugin is such a great extension to ActiveRecord I can’t imagine any non-trivial app not benefiting from it.

I have just two reservations: I would have thought it could be named better (OK that’s a niggle), and the customised with_scope methods it creates (e.g. with_active), should really be protected. Why? See this thread.

Go get scope_out - it should be in core!

Posted over 7 years back at The Hobo Blog

The scope_out plugin is such a great extension to ActiveRecord I can’t imagine any non-trivial app not benefiting from it.

I have just two reservations: I would have thought it could be named better (OK that’s a niggle), and the customised with_scope methods it creates (e.g. with_active), should really be protected. Why? See this thread.

I'm in a Magazine!

Posted over 7 years back at Cody Fauser

2 Magazine March 2007 Cover

Back in January my wife Maria and I were lucky enough to go on an all expenses paid vacation to Club Med Cancún Yucután. What was the catch? Well, the entire trip was a makeover for a magazine in Toronto called 2 Magazine.

The trip was a blast and we were fortunate enough to be photographed for the magazine by the incredible Toronto based photographer James Pattyn. The entire week was also documented on video by Mark and Evan from Viral Media Group

Special thanks to the entire 2Magazine crew including Diane, Beth, Margo, Jamie, Keri, Mark, and Evan. It was an awesome experience that we will never forget.

2 Magazine Cancun 2007 Makeover Video

Episode 13: Dangers of Model in Session

Posted over 7 years back at Railscasts

Be careful when storing a model in a session. It will behave differently than you expect and can easily get out of sync with the database. Instead of storing the model directly in the session, store the id to the model and use that to fetch it from the database.