My model looks like this:
class Job < ActiveRecord::Base
attr_accessor :start_time
def start_time
self.start_time = Time.now
end
def elapsed_time
end_time = Time.now
elapsed = end_time - self.start_time
end
end
I want to measure the elapsed time, and self.start_time exists within the start_time method. However, in my elapsed_time method, self.start_time is nil. Why is that?
I am using rails 4.1.0 and ruby 2.0.0.