Rspec2: date_select vs. i18n

Montag, 20. Juni 2011, 21:48 Uhr | roberto@vasquez-angel.de |

If you get an error like this using i18n on your forms:

  7) Admin::PeopleController as a signed in admin PUT 'update' failure should render the edit template
     Failure/Error: put :update, :locale => @locale, :id => @person, :person => @attrs.merge(:identifier => "")
     ActionView::Template::Error:
       can't convert Symbol into String
     # ./app/views/admin/people/_form.html.erb:44:in `block in _app_views_admin_people__form_html_erb__60110182_108022690__625824326'
     # ./app/views/admin/people/_form.html.erb:1:in `_app_views_admin_people__form_html_erb__60110182_108022690__625824326'
     # ./app/views/admin/people/edit.html.erb:3:in `_app_views_admin_people_edit_html_erb__1032053437_112969930__1009460369'
     # ./app/controllers/admin/people_controller.rb:66:in `block (2 levels) in update'
     # ./app/controllers/admin/people_controller.rb:61:in `update'
     # ./spec/controllers/admin/people_controller_spec.rb:127:in `block (5 levels) in <top (required)>'

You need to add the date format to your Rails.root/config/language.yml:

en:
  date:
    formats:
      default: "%Y-%m-%d"
      short: "%b %d"
      long: "%B %d, %Y"

    order:
      - :year
      - :month
      - :day

Or you get a pre-filled i18n file for your language at [https://github.com/svenfuchs/rails-i18n]