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.