Notes posted by himn1
RSS feed![Default_avatar_30](https://www.gravatar.com/avatar/2c2bc4e931e544fbbd8b28f6b04cd2f1?size=30&default=http://apidock.com/images/default_avatar_30.png)
0 thanks
![Default_avatar_30](https://www.gravatar.com/avatar/2c2bc4e931e544fbbd8b28f6b04cd2f1?size=30&default=http://apidock.com/images/default_avatar_30.png)
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"
![Default_avatar_30](https://www.gravatar.com/avatar/2c2bc4e931e544fbbd8b28f6b04cd2f1?size=30&default=http://apidock.com/images/default_avatar_30.png)
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")