Rails Custom Validation

class Hotel < ApplicationRecord  validate :check_email?   def check_email?
errors.add :base, "Hotel email must be same as user's email!"
unless self.email == self.user.email
end
end

--

--

--

Depths of ocean could not swallow me.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Integrating the authentication systems of IBM Cloud Pak for Data and Palantir Foundry

Nothing to see here. The not-so-charger

Meme Contest

OverTheWire: Bandit Level 0 & 1

RT-Thread Announces Partnership with Open Source LVGL

Manifests and Resources in Puppet.

The Unicorn Project: thought about Psychological Safety

VBA to T-SQL via TDD: Step 10

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sis Ccr

Sis Ccr

Depths of ocean could not swallow me.

More from Medium

User Auth and Password Protection: Rails

Rucy: A Ruby-to-BPF Compiler

Rails Parallel Testing and the flipper gem

Kotlin: Scope Functions