I\'ve been working with Rails for a while now and one thing I find myself constantly doing is checking to see if some attribute or object is nil in my view code before I dis
Don't forget .try, which was added in Rails 2.3. This means that you can call something like the following:
@object.try(:name)
And if @object is nil, nothing will be returned. This is perhaps the built-in solution for sameera207's idea.
Ideally, you shouldn't be sending nil objects through to the view - however it's not always possible to avoid.