mardi 1 mars 2016

Rails 3.2 model validations and I18n

I got this error after add vlidation.

NoMethodError (undefined method `i18n_key' for "question":String):

My model:

class Question < ActiveRecord::Base

  validates_format_of :text, :without => /http:\/\//i, :on => :create, :allow_blank => false, :message => I18n.t('https_only')
...
end

config/locales/en.yml:

  en:

  https_only: 'Sorry, only https links allowed.'

Aucun commentaire:

Enregistrer un commentaire