My model has a serialize :settings field. It is also validated by some custom validation. I now want to initialize that field when a开发者_StackOverflow社区n object is created (self.settings = Settings.new). So I tried to it in an after_initialization callback. But that gives me Can't convert Settings into String. The same happens when using the before_validation callback.
But when assigning the Setting.new manually after the object was built there is no problem at all. Why can't I use those callbacks to set serialization fields? (Rails3)
Make sure that your :settings field is in fact of type :text rather than :string. It might help you to check out : something similar here
加载中,请稍侯......
精彩评论