Created
March 30, 2010 19:36
-
-
Save avit/349501 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Before, I was overriding the initialize method to set the run_date. | |
# This is how I'm doing it now: | |
class ListingHighlight < ActiveRecord::Base | |
before_validation :assign_run_date | |
validates_presence_of :run_date, :on => :create | |
def run_date=( value ) | |
write_attribute :run_date, some_date_method(value) | |
end | |
def run_date | |
read_attribute :run_date or write_attribute(:run_date, some_date_method) | |
end | |
protected | |
def assign_run_date | |
run_date | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment