Skip to content

Instantly share code, notes, and snippets.

@rhysforyou
Created November 8, 2011 23:24
Show Gist options
  • Select an option

  • Save rhysforyou/1349672 to your computer and use it in GitHub Desktop.

Select an option

Save rhysforyou/1349672 to your computer and use it in GitHub Desktop.
class Post < ActiveRecord::Base
validates :content, :presence => true,
:length => {:minimum => 140}
after_initialize do
self.publish_date ||= DateTime.now
end
def published?
self.publish_date <= DateTime.now
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment