I'm trying to do validation skipping as someone described in this post. Whole process of canceling is working for me, but I've trouble with this syntax:
class User < ActiveRecord::Base
# [...]
remove_email_uniq_validation
def self.remove_email_uniq_validation
# do something
end
# [...]
end
Got:
[...] gems/activerecord-4.1.8/lib/active_record/dynamic_matchers.rb:26:in `method_missing': undefined local variable or method `remove_email_uniq_validation' for User (call 'User.connection' to establish a connection):Class (NameError)
What am I doing wrong regarding to example from Gistflow and what's a correct way to call methods like this directly in model class?
Thanks for answers
The method doesn't exist at the point you're trying to call it. Move the def in front of the call and it will work.