I’m trying to format dates in a Rails view.
<td><%= l order.ship_date, :format => :long %></td>
This doesn’t work if the date is nil:
Object must be a Date, DateTime or Time object. nil given.
What’s the best “Rails” solution?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just add a failsafe if the object is nil:
If you want to display something in case it’s nil: