hoodwink.d enhanced

Sat Nov 5

Tip Kernel#display

In Ruby, there is a little-known method called `display` defined in the Kernel module. Its job is to allow an object to print itself:


1.display # prints “1”
“ralph”.display # prints “ralph”

In Rails, it’s often tempting to create an action called `display` for, say, displaying a product’s details (http://myapp.com/product/display/1).

Don’t do it. It won’t work. And you’ll spend a lot of time not knowing why it doesn’t work.