0

Developing rails 4 application where password is not compulsory

  validates :password, length: { in: 4..20 }, on: :create, :if => :check_provider

  def check_provider
    !self.provider.nil?
  end

I put condition as you saw in above code but still error for required password.

What is wrong and how to apply password blank allow when provider is not nil.

Thanks

user1780370
  • 851
  • 1
  • 17
  • 27
  • it should work the way you use it. Are you sure your method is not called? It can also be simplified to `self.provider.present?` – roman-roman Sep 26 '14 at 14:20
  • currently you are validating the password when you have a provider... which it sounds like is the opposite of what you want? change the if to unless and verify it works as expected for both cases? – user3334690 Sep 26 '14 at 15:00
  • Fire validation when provide is not nil... but not working its always fire – user1780370 Sep 29 '14 at 12:42

0 Answers0