Skip to content

Instantly share code, notes, and snippets.

@johnd
Created May 6, 2011 13:54
Show Gist options
  • Save johnd/958982 to your computer and use it in GitHub Desktop.
Save johnd/958982 to your computer and use it in GitHub Desktop.
class Article < ActiveRecord::Base
after_validation :ensure_no_published_at_dates_in_the_future
# ...
private
def ensure_no_published_at_dates_in_the_future
self.published_at = Date.today if self.published_at > Date.today
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment