Notes posted by himn1
RSS feed
himn1 -
October 7, 2010
0 thanks
himn1 -
October 7, 2010 - (>= v3.0.0)
2 thanks
Custom validator with i18n support
Here is modified EmailValidator from the example above:
class EmailValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) record.errors.add(attribute, options[:message] || :email) unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i end end
And locale:
en: activerecord: errors: messages: email: "is not an email"
himn1 -
September 9, 2009
2 thanks
Attachment's name
Files attached in a standard way are shown up as “noname”. You can specify any name by using the :filename key:
attachment :content_type => "application/pdf", :filename => "Othersheet.pdf", :body => File.read("example.pdf")