diff options
author | Indrek Juhkam <indrek@urgas.eu> | 2012-01-22 23:47:36 +0200 |
---|---|---|
committer | Indrek Juhkam <indrek@urgas.eu> | 2012-01-22 23:47:36 +0200 |
commit | 88ec722a0ff0752e4170d41d0c956a387cd9b4db (patch) | |
tree | 2105b6246bed98b75995b46e711116d1d1758ea5 /actionpack/lib/action_view/helpers | |
parent | 4e6050b9614d178c28cce45f1c33ad9d1666e330 (diff) | |
download | rails-88ec722a0ff0752e4170d41d0c956a387cd9b4db.tar.gz rails-88ec722a0ff0752e4170d41d0c956a387cd9b4db.tar.bz2 rails-88ec722a0ff0752e4170d41d0c956a387cd9b4db.zip |
Raise exception when date.order includes invalid elements
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r-- | actionpack/lib/action_view/helpers/date_helper.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index f5077b034a..e095f832d1 100644 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -836,7 +836,15 @@ module ActionView end def translated_date_order - I18n.translate(:'date.order', :locale => @options[:locale]) || [] + date_order = I18n.translate(:'date.order', :locale => @options[:locale]) || [] + + forbidden_elements = date_order - [:year, :month, :day] + if forbidden_elements.any? + raise StandardError, + "#{@options[:locale]}.date.order only accepts :year, :month and :day" + end + + date_order end # Build full select tag from date type and options. |