I have a Date field in one of my models and rails_admin give me a nice datepicker for it. However, if a user enters an incorrectly formatted date manually (i.e. "2013") they get the following 500 error:
ArgumentError (invalid date)
Here's the end of the stack trace:
/Users/james/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/date.rb:1576:in `new_by_frags'
/Users/james/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/date.rb:1621:in `parse'
activesupport (3.1.12) lib/active_support/values/time_zone.rb:273:in `parse'
rails_admin (0.4.9) lib/rails_admin/config/fields/types/datetime.rb:49:in `parse_date_string'
rails_admin (0.4.9) lib/rails_admin/config/fields/types/datetime.rb:44:in `normalize'
rails_admin (0.4.9) lib/rails_admin/config/fields/types/date.rb:18:in `parse_input'
rails_admin (0.4.9) lib/rails_admin/config/proxyable/proxy.rb:31:in `__send__'
rails_admin (0.4.9) lib/rails_admin/config/proxyable/proxy.rb:31:in `method_missing'
rails_admin (0.4.9) app/controllers/rails_admin/main_controller.rb:102:in `sanitize_params_for!'
rails_admin (0.4.9) app/controllers/rails_admin/main_controller.rb:102:in `each'
rails_admin (0.4.9) app/controllers/rails_admin/main_controller.rb:102:in `sanitize_params_for!'
rails_admin (0.4.9) lib/rails_admin/config/actions/edit.rb:27
The full stack trace: https://gist.github.com/jamesmkur/8118398
My gemfile.lock: https://gist.github.com/jamesmkur/8118420
I tried adding validations to the field to ensure the string was parsable as a Date, but parse_date_string() is getting called before and I still get the error.
Since the parsing happens directly on a user input field, should there be a layer of validation?
thanks
I have a Date field in one of my models and rails_admin give me a nice datepicker for it. However, if a user enters an incorrectly formatted date manually (i.e. "2013") they get the following 500 error:
Here's the end of the stack trace:
The full stack trace: https://gist.github.com/jamesmkur/8118398
My gemfile.lock: https://gist.github.com/jamesmkur/8118420
I tried adding validations to the field to ensure the string was parsable as a Date, but parse_date_string() is getting called before and I still get the error.
Since the parsing happens directly on a user input field, should there be a layer of validation?
thanks