With Rails 3.2.21 and Ruby 2.2.0p0 the time zone parser is broken. With Ruby 2.1.2 this was working just fine.
 pry(main)> Time.zone.parse("2015-01-12")
NoMethodError: undefined method `year' for nil:NilClass
from /Users/user/.rvm/gems/ruby-2.2.0/gems/activesupport-3.2.21/lib/active_support/values/time_zone.rb:275:in `parse'
TLDR: rails bug that has been fixed, first fixed version on the 3.2 branch is 3.2.22
Ruby 2.2 changes how default arguments are resolved when there is a name ambiguity:
def now ... end def foo(now = now) end
In older versions of ruby calling
foo with no arguments results in the argument
now Being set to whatever the
now() method calls. In ruby 2.2 it would instead be set to nil (and you get a warning about a circular reference)
You can resolve the ambiguity by doing either
def foo(now = now()) end
def foo(something = now) end
(And obviously changing uses of that argument)
Apparently the way it used to work was a bug all along. Rails had a few places where this bad behaviour was relied on, including in AS::Timezone.parse. The fix was backported to the 3-2-stable branch and eventually released as part of 3.2.22.
The commit to rails master fixing the issue has a link to the ruby bug filed about this