skip_callback method documentation #8358

Closed
Backoo opened this Issue Nov 28, 2012 · 4 comments

3 participants

@Backoo

Probabily, for the ActiveSupport::Callbacks::ClassMethods.skip_callback method the documentation should be ( note : from :validate to :validation)

class Writer < Person
   skip_callback :validation, :before, :check_membership, :if => lambda { self.age > 18 }
end

instead of

class Writer < Person
   skip_callback :validate, :before, :check_membership, :if => lambda { self.age > 18 }
end
@steveklabnik
Ruby on Rails member

Should it? elsewhere in the file we also use :validate

@steveklabnik
Ruby on Rails member

Yeah, these are generic examples, they're not ActiveRecord specific. This is fine.

@Backoo

I don't know if those are not ActiveRecord specific, but if I use :validate then it does not work (that is, the callback is not skipped) while if I use :validation then it works.

@carlosantoniodasilva
Ruby on Rails member

@speaking it depends on which callbacks are set. That is a generic example of the underlying callbacks structure that Active Support gives you, meaning that if you used define_callbacks :validate.., you would use skip_callback :validate.

If you're using Active Record, it defines the :validation callback for you, by using internally define_callbacks :validation or something like that, giving you before_validation and after_validation callbacks. In this scenario, you will use skip_callback :validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment