Hi! Thanks for visiting my blog. If you've received any value from my content would you mind supporting my new startup by downloading our browser add-on? It's called PriceBlink and makes online shopping a breeze. You can watch it in action here and download it for Chrome, Firefox, IE, or Safari by going to PriceBlink.com. Thank you and I hope you enjoy!

Yield with Ruby on Rails

May 24

If you’ve worked with layouts in Rails then you’re most likely familiar with @content_for_layout, which basically substitutes the output of your view into the layout file. I was digging around earlier for some more information file and ran into an article talking about how <%= yield %> is preferred to <%= @content_for_layout %>. I can’t seem to dig up a link, but will update this post when I find it.

With that being said I’ve started using yield for my layout files, but am intrigued to know why it’s preferred. Maybe it’s the simple fact that yield seems to fall more in lines with Ruby’s intuitive language syntax. Speculation aside, it’s a simple change to make and you have nothing to lose in making it.

Leave a Reply