Skip to content

Instantly share code, notes, and snippets.

@rbarazi
Created March 8, 2010 21:47
Show Gist options
  • Save rbarazi/325796 to your computer and use it in GitHub Desktop.
Save rbarazi/325796 to your computer and use it in GitHub Desktop.
[Beginning Rails 3] Listing 5-17. The Article model in app/models/article.rb
class Article < ActiveRecord::Base
validates :title, :presence => true
validates :body, :presence => true
belongs_to :user
has_and_belongs_to_many :categories
has_many :comments
def long_title
"#{title} - #{published_at}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment