byroot / activerecord-typedstore

ActiveRecord::Store but with type definition
MIT License
439 stars 57 forks source link

date_select form helper fails with typed hstore #15

Open Bahanix opened 10 years ago

Bahanix commented 10 years ago

I am using activerecord-typedstore (0.4.3)

date_select form helper does not save data properly (display is ok).

http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-date_select

class Foobar < ActiveRecord::Base
  typed_store :data, coder: DumbCoder do |s|
    s.date :birthdate
  end
end
<%= form_for @foobar do |f| %>
  <%= f.date_select :birthdate %>
  <%= f.submit %>
<% end %>
ActiveRecord::MultiparameterAssignmentErrors - 1 error(s) on assignment of multiparameter attributes [error on assignment [1989, 3, 24] to birthdate (undefined method `klass' for nil:NilClass)]:
  activerecord (4.0.4) lib/active_record/attribute_assignment.rb:79:in `execute_callstack_for_multiparameter_attributes'
  activerecord (4.0.4) lib/active_record/attribute_assignment.rb:63:in `assign_multiparameter_attributes'
  activerecord (4.0.4) lib/active_record/attribute_assignment.rb:34:in `assign_attributes'
  activerecord (4.0.4) lib/active_record/core.rb:468:in `init_attributes'
  activerecord (4.0.4) lib/active_record/core.rb:185:in `initialize'
  ...

It works well with a plain old date attribute.

Thanks for your work :sunflower: