Before_validation is not called?

I have a strange problem for which I cannot find a logical explanation.

I study the error and put some records in place (via Rollbar), so I can see the evolution of some instances of one of my models.

Here is what I got:

class Connexion < ActiveRecord::Base
    before_validation :save_info_in_rollbar
    after_save :save_info_in_rollbar

    def save_info_in_rollbar
      Rollbar.log("debug", "Connexion save", :connexion_id => self.id, :connexion_details => self.attributes)
    end
end

Now I get a lot of data in the roll (almost 2 lines each time a connection is created / updated). But the strange thing is this: for some connections (=> exactly those who have defective data that I study), I do not receive data at all!

I do not understand how you can create a connection and save it in the database, and not have any trace of the log before_validation. It looks like the callback is not being called, but if I'm not mistaken, it should be the first in the reverse order => what could prevent it from being called?

β†’ , : 3 , , :

  • .connexions.create()
  • connexion.attr = "value"; connexion.save!
  • connexion.update_attributes (attr: "value" )
+4
3

, , 2 , , (, , Rollbar).

haha ​​

+1

, , :

: , . , Im , ActiveRecord/ActiveModel .

+4

-, self , .

-, , . Rails: Rails 3

-, .

0

All Articles