Skip to content

Instantly share code, notes, and snippets.

@diegorv
Created February 13, 2009 16:31
Show Gist options
  • Save diegorv/63982 to your computer and use it in GitHub Desktop.
Save diegorv/63982 to your computer and use it in GitHub Desktop.
class Article < ActiveRecord::Base
has_permalink :title
belongs_to :category
has_attached_file :image, :styles => { :thumb => "100x100>" }
def to_param
"#{permalink}"
end
end
class Category < ActiveRecord::Base
has_permalink :name
belongs_to :edition
has_many :articles
validates_presence_of :name, :message => "não pode ficar em branco."
def to_param
"#{permalink}"
end
end
class Edition < ActiveRecord::Base
has_many :categories
has_many :articles
validates_presence_of :number, :message => "não pode ficar em branco."
validates_presence_of :description, :message => "não pode ficar em branco."
validates_numericality_of :number, :message => "tem que ser um numero."
validates_uniqueness_of :number, :message => "tem que ser unico."
has_attached_file :photo, :styles => { :thumb => "100x100>" }
validates_attachment_presence :photo, :message => "você tem que por uma foto."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment