daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Sep 14th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. How to chain try() and scoped to_s() in Rails?
  2. @model.try(:date)
  3.    
  4. @model.try(:date).try(:to_s)
  5.    
  6. @model.try(:date).try(:to_s(:long))
  7. @model.try(:date).try(:to_s).try(:long)
  8.    
  9. Person.try(:find, 1)
  10.    
  11. @model.try(:date).try(:to_s, :long)
  12.    
  13. @model.try(:date).try(:to_s(:long))
  14.    
  15. @model.try(:date).try(:to_s).try(:long)
  16.    
  17. @model.date.to_s(:long) rescue nil
  18.    
  19. l @model.date, format: :long rescue nil
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top