conditional validation not null/nil

46 views
Skip to first unread message

fugee ohu

unread,
Mar 29, 2017, 8:37:33 AM3/29/17
to Ruby on Rails: Talk
Trying to validate presence where another field is not null
I found this example, the opposite

class Person < ApplicationRecord
  validates :surname, presence: true, if: "name.nil?"
end

How do I change the if: condition to name not nil?

Colin Law

unread,
Mar 29, 2017, 8:45:22 AM3/29/17
to Ruby on Rails: Talk
Why have you asked twice? I have responded to the other one.

Colin
Reply all
Reply to author
Forward
0 new messages