Created
December 9, 2013 12:46
-
-
Save rajeevkannav/7871761 to your computer and use it in GitHub Desktop.
#Fixme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
private | |
def padded_data | |
#FixME: write logic here | |
end | |
end | |
class Category < ActiveRecord::Base | |
#Validations | |
validates :name, presence: true, length: {in: 6..200} | |
validates :state, presence: true, length: {in: 0..20} | |
#Association | |
belongs_to :category | |
has_many :subcategories, class_name: 'Category', dependent: :destroy | |
has_many :posts | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment