Skip to content

Instantly share code, notes, and snippets.

@bradylove
Created March 26, 2011 14:30
Show Gist options
  • Save bradylove/888322 to your computer and use it in GitHub Desktop.
Save bradylove/888322 to your computer and use it in GitHub Desktop.
class Post < ActiveRecord::Base
before_save :published_at_value
private
# TODO: Needs Refactoring
def published_at_value
if self.published == true and self.published_at.nil? == true
self.published_at = Time.now
elsif self.published == false
self.published_at = nil
elsif self.published == true and self.published_at.nil? == false
self.published_at = published_at
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment