Is it possible to conditionally serialize an attribute like so:
# answer.rb
serialize :content, :if => :has_options
attr_accessible :content, :form_id, :question_id
belongs_to :question
def has_options
!self.answer.question.options.blank?
end
I’ve tried this but it’s a no go. Thanks!
As far as I know, there is no conditional option to
serialize.What I would do is remove the
:contentfromattr_accessibleand do abefore_savefilter in which you set the:contentunder your conditions