Sunday, February 05, 2006

Using partial in views and controllers

In views/unajax/index.rhtml

<ul id="items"><br /><%= render(:partial => 'item', :collection => @items) %><br /></ul><br />

In controllers/unajax_controller.rb
<br />def<br />item = Item.new(params[:item_body])<br />render(:partial => "item", :object => item, :layout => false)<br />end<br />
And in views/unajax/_item.rhtml

<li><br /><p><br /><%= item.posted_on.strftime("%H:%M:%S") %>:<br /><%= h(item.body) %><br /></p><br /></li><br />
Notes from Agile devel book

0 Comments:

Post a Comment

<< Home

eXTReMe Tracker