Prettier code in views for chained values?

Hi,

Mario T. Lanza wrote:

Sometimes in a view I have written wretchedly, ugly code like this:

<%= @person.company.address.city if @person and @person.company and
@person.company.address and @person.company.address.city %>
  

you can try

<%= @person.company.address.city rescue nil %>

That way, if everything's fine you get the value or else you get nothing.

regards,

javier ramírez