# Rails idioms?

**URL:** <https://www.ruby-forum.com/t/rails-idioms/79753>\
**Category:** Rails\
**Created:** [December 18, 2006, 6:57pm UTC](https://www.ruby-forum.com/t/rails-idioms/79753 "2006-12-18T18:57:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajkumar\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/fbc32d/32.png) [@Rajkumar\_S](https://www.ruby-forum.com/u/Rajkumar_S)\
**Post date:** [December 18, 2006, 6:57pm UTC](https://www.ruby-forum.com/t/rails-idioms/79753/1 "2006-12-18T18:57:59Z")

</div>

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,

1. 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.

2. 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

---

<div class="post-metadata">

**Author:** ![Rajkumar\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/fbc32d/32.png) [@Rajkumar\_S](https://www.ruby-forum.com/u/Rajkumar_S)\
**Post date:** [December 19, 2006, 1:38pm UTC](https://www.ruby-forum.com/t/rails-idioms/79753/2 "2006-12-19T13:38:06Z")

</div>

Rajkumar S wrote:

> 🙂
> 
> Also what are your favorite idioms, that you would like to share?
> 
> with regards,
> 
> raj
> 
> >

Check out:

> **[Select a Reject — err.the\_blog](http://errtheblog.com/post/44)**
>
> Err the Blog: Ruby and Rails from the front.

for lots of cool stuff (and subscribe to his blog – it’s a goldmine)

---

<div class="post-metadata">

**Author:** ![Rajkumar\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/fbc32d/32.png) [@Rajkumar\_S](https://www.ruby-forum.com/u/Rajkumar_S)\
**Post date:** [December 19, 2006, 3:24pm UTC](https://www.ruby-forum.com/t/rails-idioms/79753/3 "2006-12-19T15:24:08Z")

</div>

On 12/19/06, Chris T [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [Select a Reject — err.the\_blog](http://errtheblog.com/post/44)  
> for lots of cool stuff (and subscribe to his blog – it’s a goldmine)

Very true. Thanks for the link.

raj

---

<div class="post-metadata">

**Author:** ![Rajkumar\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/fbc32d/32.png) [@Rajkumar\_S](https://www.ruby-forum.com/u/Rajkumar_S)\
**Post date:** [December 20, 2006, 12:20am UTC](https://www.ruby-forum.com/t/rails-idioms/79753/4 "2006-12-20T00:20:34Z")

</div>

On Dec 18, 12:55 pm, “Rajkumar S” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 🙂
> 
> Also what are your favorite idioms, that you would like to share?

This RubyGarden page is a good reference:

[http://wiki.rubygarden.org/Ruby/page/show/RubyIdioms](http://wiki.rubygarden.org/Ruby/page/show/RubyIdioms)

Best,

-r

> with regards,
> 
> raj

–  
Ryan R.  
[http://raaum.org](http://raaum.org)  
[http://rails.raaum.org](http://rails.raaum.org) – Rails docs  
[http://locomotive.raaum.org](http://locomotive.raaum.org) – Self contained Rails for Mac OS X
