I have a field that may be blank, so I need to use Object.try, but I'm having trouble with the syntax when adding the date format.
<%= @request.assigned_date.strftime("%m/%d/%y") %>
How would I change the above to include the ".try" ?
Thanks in advance. Katie
I'd say...
<%= @request.assigned_date.try(:strftime, "%m/%d/%y") %>
Note that it wouldn't work if your field was an empty string. It has to be nil.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With