0
我为什么我用simple_form和hstore得到'undefined method'?
class User < ActiveRecord::Base
attr_accessible :email
validates :email,
presence: true
serialize :data, ActiveRecord::Coders::Hstore
end
和
<%= simple_form_for User.new do |f| %>
<%= f.input :email %>
<%= f.input :first_name %>
<%= f.input :zipcode %>
<%= f.button :submit, 'Sign up' %>
<% end %>
为什么当我想Sign up
我得到一个错误:
undefined method `zipcode' for #<User:0x007fd397631650>
完全跟踪: https://gist.github.com/3c9df05758ea3d486989
zipcode是'data'散列中的一个属性吗?如果是这样,我不认为你可以以这种方式访问它,我怀疑simple_form将处理序列化字段。也许这个线程可以帮助你http://stackoverflow.com/questions/9613208/serialized-hash-field-and-simple-form – 2013-04-30 13:52:10
以及为什么它应该工作? – fotanus 2013-04-30 14:00:00