# Best Practice: render :partial

**URL:** <https://www.ruby-forum.com/t/best-practice-render-partial/104192>\
**Category:** Rails\
**Created:** [May 15, 2007, 8:25am UTC](https://www.ruby-forum.com/t/best-practice-render-partial/104192 "2007-05-15T08:25:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 15, 2007, 8:25am UTC](https://www.ruby-forum.com/t/best-practice-render-partial/104192/1 "2007-05-15T08:25:06Z")

</div>

I have been using “render :partial” throughout my application but have  
just realised that I am perhaps not using it in the way intended.

I am for example referencing instance variables directly within my  
partial and not passing them as either an :object or a local variable  
(:locals). On reflection, this seems bad practice.

For example, I have a partial called  
“property\_name” ("\_property\_name.rhtml") that renders a text input  
field:

\<% if @property.class == PropertyCollection %\>

What would you like to call this collection?  
\<% else %\>

What would you like to call this?  
\<% end %\> \<%= text\_field :property, :name %\>

I wrote this as a partial because I use it within both create and edit  
forms, and I wanted to avoid duplication.

As you can see I am currently referring to @property.

Any advice on how I might refactor the above would be much  
appreciated.

Thanks.
