I nned to get an associsted name from one table dependent on the related
id value in another table when rendering the view but cant figure out
the syntax to handle pontential empty values:-


i.e. docv.policy_id OR docv.standard_id will exist and therefore link
back to the  policies OR the standards table respectively but ONLY ONE
will exist.

Therefore I need to check the existance of each field before attempting
to get the PolicyName OR StandrdsName from the related table otherwise
the empty item gives me a '.nil value' error.

<% @docversions.each do |docv| %>
<tr>
<td><% docv.modifier %></td>
<td><%= docv.comment %></td>
<td><%= docv.policy.PolicyName if docv.policy_id %></td>
<td><%= docv.standard.StandardsName if docv.standard_id %></td>

Can someone advise the syntax to use in the view to achieve this. I have
also tried ....."if !docv.standard_id.empty?".

Thanks
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to