This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.
When multiple validations share the same if: condition, or multiple callbacks share the same only: constraint, you end up repeating yourself. with_options groups them together. Instead of… …repeating conditions across multiple validations: class Article < ApplicationRecord validates :title , presence: true , if: :published? validates :body , length: { minimum: 100 }, if: :published? validates…
Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.