Read my latest article: 8 things I look for in a Ruby on Rails app (posted Thu, 06 Jul 2017 16:59:00 GMT)

MySQL is just a toy

Posted by Thu, 11 Sep 2008 17:04:00 GMT

Twitterrific

Are you using PostgreSQL? EnterpriseDB want’s to hear your story at Postgres Rocks

DRY(a): Year After Year

Posted by Tue, 25 Mar 2008 02:05:00 GMT

I’m guilty of it. Many of you are likely guilty of it… and I know that several customers of our Rails Code Audit and Review service are guilty of it.

How many times have you realized (after a few months has passed) that your Copyright date/year on your web site was no longer current?

How many of you had the same problem last year? The year before?

Let me share some advice with you all… DRY (a)!

Don’t Repeat Yourself (again)!

This is really a simple problem to fix but when we’re busy tackling bigger problems… little things like this slip by. Don’t worry, you’re not the only one who was reminded by a colleague three months into the year that you forgot to update this.

On client projects, we have a handful of helpers that we drop into the application. We’re starting to extract more of these into plugins and will be releasing those as time permits. It just happened that I found myself looking at yet-another Rails code base this afternoon that was showing 2007 in the footer. An easily forgivable offense.. but if you’re going to go in there and change it (again), take a moment to do the right thing. ;-)

Our solution at Planet Argon on client projects is to create a basic view helper that renders the current year. This allows us to do the following.


  <div id="footer">
    &copy; Copyright <%= current_year -%>. All Rights Reserved.
  </div>

The helper code looks like:


  # add to application_helper.rb
  module ApplicationHelper
    def current_year
      Time.now.strftime('%Y')
    end
  end

Voila. Not rocket science.. is it?

Guess what? I’m getting really tired of adding this to every Rails project that I touch. So, I bottled this little gem into a new Rails plugin that we’ll just add to future projects.

Introducing Year after Year

This is really the smallest plugin that I could put together (and it includes specs!)

What does it provide you?

YearAfterYear will provide you a helper that will render the current year (dynamically)! That’s right… just add the plugin to your Rails application and you too can enjoy New Years 2009 without having to have a deployment ready with a one line change from 2008 to 2009!

To use.. add the following to any view from within Ruby on Rails.


  <%= current_year -%>

Installation

As I’m using git, you’ll need to grab this and put it into vendor/plugins. That’s it!

You can grab it on GitHub!

Happy New Years (8+ months early)!

Just a friendly reminder to not forget the small stuff… because your visitors will notice! ;-)

Updates…

I got a few requests for this to also provide a range of years for people who like to do: 2005-2007. So this is now provided as well.

year_range(start_year)

Example:

  <%= year_range(2005) %> # => 2005-2008

Chad Fowler's Dirty Little Secret?

Posted by Sat, 06 Oct 2007 19:00:00 GMT

I saw this photo of the Microsoft team from 1978 on Anselm’s flickr and thought, “Hmm, that looks like Chad Fowler!”

Could this be Chad Fowler’s dirty little secret?..

Happy Saturday!

89 gmail invites available!

Posted by Fri, 27 Jul 2007 20:10:00 GMT

While everyone else is trading their pownce and skitch invites, I wanted to let everyone know that I still have 89 gmail invites available.

Post a comment on my blog and I’ll hook you up!

Happy Friday! ;-)

update: only 12 left!

I Repeat... Do Not Use PostgreSQL!

Posted by Tue, 14 Mar 2006 14:16:00 GMT

3 comments Latest by Rick M. Wed, 15 Mar 2006 01:38:40 GMT

Why is everybody interested in using PostgreSQL? We all know that it’s a pain to install, a pain to maintain, and Rails only works with MySQL. So, why do we bother?

This article titled, Five reasons why you should never use PostgreSQL. Ever. clears up these questions.

My favorite is… “Reason #5: You (don’t) get what you (don’t) pay for”

Imagine if we said the same thing about Ruby on Rails?

Similar Post(s): The bitter-sweet taste of agnostic database schemas, Localization with Rails and PostgreSQL, part 1