Hello,
I am a pretty new rails (and ruby) programmer, and learning the art
and craft of rails programming. One thing I noticed about rails
programming is that unlike perl there is usually one and only one cute
and sweet way of doing a thing. Let me give 2 examples,
-
I want to check if a variable is null and assign it a value if it’s
null. In other languages I would write an if clause to do this, but in
rails the sweet way would be to use the ||= operator. -
I want to render a table in a rails view. Normal way would be to
write a loop, but the rails way is to use partials and pass the
collection.
I discovered these 2 techniques recently, and it got me to think these
2 are not the only such idioms and the beauty of ruby allows lots of
such nifty techniques. But even after some googling around I am not
aware of any site where these are collected and act as resources for
programmers picking up ruby and rails. But I am sure there and such
sites and more such nice idioms in rails and ruby, but where are they?
Also what are your favorite idioms, that you would like to share?
with regards,
raj