adzap / validates_timeliness
- Source
- Commits
- Network (8)
- Issues (2)
- Downloads (15)
- Wiki (1)
- Graphs
-
Branch:
master
Loading…
Labels
master
click here to add a description
click here to add a homepage
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.
The plugin was woking very nice, but I changed the default locale to :es in enviroment.rb:
config.i18n.default_locale = :es
The when I ran my specs I got this error whenusing should validate_date and should validate_time:
"private method `gsub' called for nil:NilClass"
after half an hour I realize the real problem was that these keys where not defined in es.yml:
validates_timeliness:
error_value_formats:
date: '%Y-%m-%d'
time: '%H:%M:%S'
datetime: '%Y-%m-%d %H:%M:%S'
When this happend those helpers should give you a more readable message.

I will look into this. What version of the plugin are you using?
Hi! validates_timeliness v2.2.2, rails 2.3.2, ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]. Thank you!
finally got round to playing with this and noticed a couple of deficiencies in the code. I have changed the way I encode the multi param values into a string to better allow for missing and invalid values.
All this functionality is very hackish and mostly serves a useful purpose when I use multiple test fields for date/time fields instead the default selects. So I am thinking of removing it come version 3.
But for now could please test the changes from master installed as a plugin to see if you problem is solved
Thanks
Adam
Can you please test if your problem is solved with v2.3.0. Thanks.