Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Custom Error Message Rails plugin

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 custom_error_message.gemspec
Octocat-spinner-32 init.rb
README.md

Custom Error Message

This plugin gives you the option to not have your custom validation error message prefixed with the attribute name.

Rails 3 and Ruby 1.9

Custom Error Message is Rails 3 and Ruby 1.9 compatible

Usage

Sometimes generated error messages don't make sense.

validates_acceptance_of :accepted_terms, :message => 'Please accept the terms of service'

This generates the error message:

Accepted terms Please accept the terms of service

This plugin uses the carat (^) to omit the name of the attribute from error messages:

validates_acceptance_of :accepted_terms, :message => '^Please accept the terms of service'

This now generates:

Please accept the terms of service

CREDITS

This plugin was originally written by David Easley (easleydp@gmail.com)

Something went wrong with that request. Please try again.