While working in rails we make use of partials very often and there are case where we make use of same partial for different scenario. We try to achieve the same by passing default parameter for some unwanted variable which might case issue. Passing the default value for that variable in all the location you render the partial is tedious and error-prone.
Instead of this we can catch whether a variable have been passed for a particular partial or not but we can't use defined? operator to do this. The ActionView documentation says it's an implementation restriction.
So here is the way you can check whether the variable is available. Use local_assigns Hash.
<% if local_assigns.has_key? :name %>
<%= name %>
<% end %>
The local_assigns Hash contains all the locals you passed to the partial