mardi 19 avril 2016

Dont set value is false in callback before_create in rails 4

I Have a Model

module Interspire
  class InterspireLead < ActiveRecord::Base
    before_create :update_contactable

    def update_contactable
      self.contactable = false #contactable datatype is boolean
    end
  end
end

But when i create a object.

a = Interspire::InterspireLead.create(:email => "abc@gmail.com")
a.valid?
  #=> true
a.errors.full_messages
  #=>[]
a.save
  #=>  ROLLBACK

How to fix this erorrs?

Aucun commentaire:

Enregistrer un commentaire