Sha256: 1c02e3fc006e96ea5aa5c107b54a3264549065e4060fee8a6cc26a17db50d15c
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
class Article < ActiveRecord::Base # With default error messages. validates_presence_of :title validates_length_of :description, :minimum => 10 # With your own message with L10n. # old style(Backward compatibility). # blog.po in RAILS_ROOT/po/*/ is used. # validates_presence_of :title, :message => _("can't be empty") # validates_length_of :description, :minimum => 10, :message => _("is too short (min is %d characters)") # new style (you can use %{fn} and %d freely in the message) # blog.po in RAILS_ROOT/po/*/ is used. # validates_presence_of :title, :message => _("%{fn} can't be empty!") # validates_length_of :description, :minimum => 10, :message => _("%{fn} is too short (min is %d characters)") # # you can also redefined the title/explanation of the top of the error message. # # def error_message_title(num, record) # n_("%{num} error prohibited this %{record} from being saved", # "%{num} errors prohibited this %{record} from being saved", num) % # {:num => num, :record => record} # end # # def error_message_explanation(num) # n_("There was a problem with the following field:", # "There were problems with the following fields:", num) % {:num => num} # end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gettext-1.2.0-mswin32 | samples/rails/app/models/article.rb |
gettext-1.2.0 | samples/rails/app/models/article.rb |