1

In my Rails 4 app, i'd rather not have the default error validation messages so I'm using this (until I finally get around to client side validations).

validates :title, presence: true, :presence => { :message => "is required." }

By default this gets rendered as

Title is required.

How can I remove the :title, and submit my own message like:

:message => "Please add a title to your collection."

Any help is appreciated. As always, thanks!

Justin
  • 4,922
  • 2
  • 27
  • 69

1 Answers1

2

here is the example I have in for my code, you should try out errors.add :base, "your message here"

validate :or_fields



def or_fields
      if self.phone.blank? && self.phone2.blank? && self.email.blank? && self.email2.blank?
        errors.add :base, "You must enter either one Phone or one Email"
      end
    end
jimagic
  • 4,045
  • 2
  • 28
  • 49