Guest User

Untitled

a guest
Jan 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #
  2. # ERB
  3. #
  4. # <% years = (Date.today.year..Date.today.year + 12).collect %>
  5. # <%= f.select(
  6. # 'ccexpy',
  7. # years.zip(years.collect {|y| y.to_s[-2,2]}),
  8. # {},
  9. # { :class => "expirydate" }
  10. # ) %>
  11.  
  12.  
  13. #
  14. # EXPECTED VALUE OF years:
  15. #
  16. # [
  17. # [2011, "11"],
  18. # [2012, "12"],
  19. # [2013, "13"],
  20. # [2014, "14"],
  21. # [2015, "15"],
  22. # [2016, "16"],
  23. # [2017, "17"],
  24. # [2018, "18"],
  25. # [2019, "19"],
  26. # [2020, "20"],
  27. # [2021, "21"]
  28. # ]
  29.  
  30.  
  31. #
  32. # Pure Ruby example (no ERB)
  33. #
  34.  
  35. years = (Time.now.year..Time.now.year + 12).collect
  36. p years.zip(years.collect {|y| y.to_s[-2,2]})
Add Comment
Please, Sign In to add comment