Skip to content

Instantly share code, notes, and snippets.

class Post < ActiveRecord::Base
#Validations
validates :data, presence: true, length: {in: 6..200}
validates :source, presence: true, length: {in: 3..200}
validates :state, presence: true, length: {in: 0..20}
#Callbacks
after_save :padded_data
#Associations
has_many :subcategories, class_name: 'Category'
has_one :category, :through => :subcategories