Hi!
I've a problem with select_date and not completed selection (ex. select only year and post)
This doesn't go well because plugin doesn't handle a nil value from ValidatesTimeliness::Formats.parse(raw_value, :datetime) on ValidatesTimeliness::ActionView::InstanceTag::value_with_timeliness method (validates_timeliness/lib/validates_timeliness/action_view/instance_tag.rb:31)
This generates an error:
ActionView::TemplateError (You have a nil object when you didn't expect it!
You might have expected an instance of Array.
Backtrace:
/home/giulio/myproject/trunk/vendor/plugins/validates_timeliness/lib/validates_timeliness/action_view/instance_tag.rb:42:in value'
/home/giulio/myproject/trunk/vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:920:indatetime_selector_without_timeliness'
/home/giulio/myproject/trunk/vendor/plugins/validates_timeliness/lib/validates_timeliness/action_view/instance_tag.rb:28:in datetime_selector'
/home/giulio/myproject/trunk/vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:907:into_date_select_tag_without_error_wrapping'
/home/giulio/myproject/trunk/vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb:268:in to_date_select_tag'
/home/giulio/myproject/trunk/vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:186:indate_select'
/home/giulio/myproject/trunk/vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb:964:in date_select'
/home/giulio/myproject/trunk/app/views/people/_form.html.erb:40:inrun_erb_app47views47people47_form46html46erb_locals_f_form_object'
/home/giulio/myproject/trunk/app/views/people/edit_form.html.erb:6:in _run_erb_app47views47people47_edit_form46html46erb_locals_edit_form_object'
/home/giulio/myproject/trunk/app/views/people/_edit_form.html.erb:5:in_run_erb_app47views47people47_edit_form46html46erb_locals_edit_form_object'
/home/giulio/myproject/trunk/app/views/people/edit.html.erb:2:in _run_erb_app47views47people47edit46html46erb'
/home/giulio/myproject/trunk/app/controllers/people_controller.rb:93:inupdate'
/home/giulio/myproject/trunk/app/controllers/people_controller.rb:84:in `update'
I fix this problem with a check
time_array = ValidatesTimeliness::Formats.parse(raw_value, :datetime)
unless time_array.nil?
TimelinessDateTime.new(time_array[0..5])
else
TimelinessDateTime.new([0,0,0,0,0,0])
end
But this fills wrong the year select with values around year 0 (-2 -1 0 1 2...) because it relies on base year.
Ty
G.
This is also an issue when you pass a lambda with no params to :after - it works in 1.8, but throws an argument error in 1.9, which is captured (incorrectly) by the non-specific rescue block, resulting in the unhelpful "restriction 'after' value was invalid" error.
To fix, only catch exceptions that you actually expect.
Sorry I missed this issue comment. Yes absolutely, fixed exception catching and latest version supports 1.9.