Created
March 26, 2011 14:30
-
-
Save bradylove/888322 to your computer and use it in GitHub Desktop.
This file contains 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 | |
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