Skip to content

Instantly share code, notes, and snippets.

@yumitsu
Created December 18, 2010 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yumitsu/746056 to your computer and use it in GitHub Desktop.
Save yumitsu/746056 to your computer and use it in GitHub Desktop.
class Article < ActiveRecord::Base
belongs_to :author, :class_name => "User", :foreign_key => "user_id"
validates_presence_of :title
validates_presence_of :content
has_foreign_language :title
has_foreign_language :content
validates_attachment_content_type :image, :content_type => [ 'image/jpeg', 'image/jpg', 'image/gif', 'image/png' ], :message => "не является изображением"
has_attached_file :image, :path => ":rails_root/public/assets/:id/:style_:basename.:extension",
:url => "/public/assets/:id/:style_:basename.:extension",
:styles => {
:standart => "300x300>",
:medium => "200x200>"
}
validate :test_validator
protected
def test_validator
if self.huipizda != true
self.errors.add(:huipizda, 'assertion failed')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment