The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
What's New in Edge Rails: render Stops Being High-Maintenance

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
rwdaigle

Posts: 312
Nickname: rwdaigle
Registered: Feb, 2003

Ryan is a passionate ruby developer with a strong Java background.
What's New in Edge Rails: render Stops Being High-Maintenance Posted: Nov 19, 2008 7:48 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by rwdaigle.
Original Post: What's New in Edge Rails: render Stops Being High-Maintenance
Feed Title: Ryan's Scraps
Feed URL: http://feeds.feedburner.com/RyansScraps
Feed Description: Ryan Daigle's various technically inclined rants along w/ the "What's new in Edge Rails" series.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by rwdaigle
Latest Posts From Ryan's Scraps

Advertisement

render is one of those oft-used view-helper methods that always seems to be a little cumbersome. The most common use is to render a partial within another view:


render :partial => 'articles/article', :locals => { :article => @article }

But this is a lot of work for a simple operation, and now it becomes much simpler. Now the default is to assume that a partial is requested (in the past render a :file was the default) and that the final hash argument is the locals hash. Here is the above functionality using the new syntax:

1
2
3
4
5
6
7
8
9
# Render the 'article' partial with an article local variable
render 'articles/article', :article => @article

# Or even better (same as above)
render @article

# And for collections, same as:
# render :partial => 'articles/article', :collection => @articles
render @articles

If you’ve got some old render calls hanging around that aren’t using partials you’ll have to specify the :file option now:


render :file => 'original'

Hassle free partial rendering. Yay.

tags: ruby, rubyonrails

Read: What's New in Edge Rails: render Stops Being High-Maintenance

Topic: Grails vs. Rails: Are we seriously still talking about this?! Previous Topic   Next Topic Topic: Rubinius is a community project

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use