On 29 June 2010 08:40, Carsten Gehling <lists@ruby-forum.com> wrote:
> I have a site with a lot of view code like this:
>
> <p>
> <%=@post.user.name%>
> </p>
>
> Unfortunately a lot of old posts have had their users deleted, so the
> code above breaks the entire view. I am working on a larger cleanup on
> the code, but in the meantime I would like to make a quickfix to get the
> views working.
>
> What I would like is to convert
>
> <%=@post.user.name%>
<%= @post.user.name if @post.user %>
Colin
>
> to
>
> <%=(@post.user.name) rescue ''%>
>
> Is there any way to override <%= to do the above? Thus fixing all errors
> on the spot.
>
> Thanks
>
> - Carsten
> --
> 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 rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment