27 Jun, 2008

Published at 07:27AM

Tagged with code, programming, and rails

This post has 1 comment

Rails' StringInquirer

A recent commit to Rails. When the last method of a method chain ends with a question mark, the entire chain reads like a question.

1
2
3
4
5
$> Rails.env == 'production'
$> # => true

$> Rails.env.production?
$> # => true

The latter is much better. I love these smart little additions. Any string wrapped up in a StringInquirer has this functionality.

Comments

Jeremy Thursday, 18 Feb, 2010 Posted at 07:01AM

This is nil/false though, which is at best annoying:

‘production’ == Rails.env

Do you have something to say about this post?
Retype the image to the right Spam Hint: Are You Human? Textile Formatting Tips

or

Ryan Heath | Site Management A Ruby on Rails production.

This site is a Formed Function. Formed Function LLC | @formedfunction | Get in Touch