[Rails] Add a "filter" on the ERB <%= ... %>
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%>
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home