title: Setting the values of a model in Rails
body: <p>I am having a strange problem in Rails.  I want to set the value of a field in an model in Rails, but I can't do it, even in the rails console.  Observe:</p>
  
  <pre><code>1.9.3p393 :008 &gt; campy = Campaign.last
    Campaign Load (0.8ms)  SELECT `campaigns`.* FROM `campaigns` ORDER BY `campaigns`.`id` DESC LIMIT 1
   =&gt; #&lt;Campaign id: 3, name: "Stuff", ..., approved_at: nil, approval_requested_at: nil&gt; 
  1.9.3p393 :009 &gt; campy.approved_at = Time.now
   =&gt; 2013-07-01 00:54:38 +0200 
  1.9.3p393 :010 &gt; campy.save
     (0.2ms)  BEGIN
     (0.2ms)  COMMIT
   =&gt; true 
  1.9.3p393 :011 &gt; campy.approved_at
   =&gt; 2013-07-01 00:54:38 +0200 
  1.9.3p393 :012 &gt; Campaign.last.approved_at
    Campaign Load (0.7ms)  SELECT `campaigns`.* FROM `campaigns` ORDER BY `campaigns`.`id` DESC LIMIT 1
   =&gt; nil 
  1.9.3p393 :013 &gt; campy = Campaign.last
    Campaign Load (0.6ms)  SELECT `campaigns`.* FROM `campaigns` ORDER BY `campaigns`.`id` DESC LIMIT 1
   =&gt; #&lt;Campaign id: 3, name: "Stuff", ..., approved_at: nil, approval_requested_at: nil&gt; 
  1.9.3p393 :014 &gt; campy.approved_at = Time.now
   =&gt; 2013-07-01 00:55:11 +0200 
  1.9.3p393 :015 &gt; campy.save
     (0.3ms)  BEGIN
     (0.2ms)  COMMIT
   =&gt; true 
  1.9.3p393 :016 &gt; Campaign.last.approved_at
    Campaign Load (0.7ms)  SELECT `campaigns`.* FROM `campaigns` ORDER BY `campaigns`.`id` DESC LIMIT 1
   =&gt; nil 
  </code></pre>
  
  <p>I am trying to set the value of the last Campaign's approved_at attribute to Time.now, but it remains nil, even after I save it.  approved_at is made available via the attr_accessor function in the top of Campaign's model.  Why can't I change the value of this attribute?</p>
  
  <p>Edit:</p>
  
  <p>Another interesting aspect of the problem is that when I set campy.approved_at and then look up the value explicitly, I get the correct value.  However, when I look at campy as a variable, Rails still shows the value as nil</p>
  
  <pre><code>1.9.3p393 :027 &gt; campy.approved_at = Time.now
   =&gt; 2013-07-01 01:19:05 +0200 
  1.9.3p393 :028 &gt; campy.save
     (0.2ms)  BEGIN
     (0.2ms)  COMMIT
   =&gt; true 
  1.9.3p393 :029 &gt; campy.approved_at
   =&gt; 2013-07-01 01:19:05 +0200 
  1.9.3p393 :030 &gt; campy
   =&gt; #&lt;Campaign id: 3, name: "Stuff", ... , approved_at: nil, approval_requested_at: nil&gt; 
  </code></pre>