title: How can i override an attribute from another virtual attribute in a model?
body: <p>I have a virtual attribute <code>start_date</code> and a database column <code>start</code> (datetime).</p>
  
  <p>How can i override the date (but not the time) of <code>start</code> with the date from <code>start_date</code>?</p>
  
  <p>I tried this in the setter method and the logger says that self.start/start is set, but in the database and also the update log <code>start</code> has still the old date.</p>
  
  <pre><code># model: db table with columns: id(int), start(datetime)
  class DateTimeTest &lt; ActiveRecord::Base
  
    attr_accessible :start_date, :start
  
    def start_date=(value)
      logger.debug '&gt;&gt;&gt;&gt;' + start.inspect
      logger.debug '&gt;&gt;&gt;&gt;' + self.start.inspect
      start = DateTime.new(value.to_date.year, value.to_date.month, value.to_date.mday, 15,15,15)
      self.start = DateTime.new(value.to_date.year, value.to_date.month, value.to_date.mday, 15,15,15)
      logger.debug '&gt;&gt;&gt;&gt;' + start.inspect
      logger.debug '&gt;&gt;&gt;&gt;' + self.start.inspect
    end
  
  end
  
  # view
  &lt;%= simple_form_for(@datetimetest) do |f| %&gt;
    &lt;%= f.input :start_date, :as =&gt; :string %&gt;
    &lt;%= f.input :start %&gt;
    &lt;%= f.button :submit %&gt;
  &lt;% end %&gt;
  
  # controller is a base scaffolding controller
  </code></pre>
  
  <p>In the logs i can see that <code>start</code> is populated:</p>
  
  <pre><code>Parameters: {..., "datetimetest"=&gt;{"start_date"=&gt;"03.05.2012", "start(1i)"=&gt;"2012", "start(2i)"=&gt;"5", "start(3i)"=&gt;"1", "start(4i)"=&gt;"13", "start(5i)"=&gt;"05"}
  </code></pre>