Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoMethodError (undefined method `validate' for true:TrueClass)

This specific line in my model

validates :password, 
     length: { minimum: 8 }, 
     allow_nil: true, 
     on: :create, 
     unless: (:uid.present? && :provider.present?)

is causing

NoMethodError (undefined method `validate' for true:TrueClass)

and no errors during update_user.

Is there any syntax mistake? maybe something like the arguments are not sent properly or is it something else?

like image 604
Saravanabalagi Ramachandran Avatar asked Apr 13 '26 18:04

Saravanabalagi Ramachandran


1 Answers

This error is occuring becuase of

unless: (:uid.present? && :provider.present?)

so replace it with

unless: Proc.new{|u| u.uid.present? && u.provider.present?}

and it will work.

Let me know if you are still facing the issue.

like image 109
Pradeep Agrawal Avatar answered Apr 15 '26 07:04

Pradeep Agrawal