title: DateTime and DataMapper
body: <h1>Problem</h1>
  <p>I'm essentially trying to save +4 hours from now in DM. I think the DateTime is correct, but the DataMapper doesn't work properly. Any ideas?</p>
  <h1>Controller</h1>
  <pre><code>p DateTime.now
  t = DateTime.now + params[:hours] / 24
  p t
  reward = @player.work params[:hours]
  action = Action.new(:player =&gt; @player, :type =&gt; 0, :completed_at =&gt; t, :reward =&gt; reward)
  </code></pre>
  <h1>model</h1>
  <pre><code>class Action
  include DataMapper::Resource
  
  property :id, Serial
  property :type, Integer
  property :completed_at, DateTime
  property :reward, Integer
  
  TYPES = {
    0 =&gt; &quot;Work&quot;,
    1 =&gt; &quot;Arena&quot;,
    2 =&gt; &quot;Quest&quot;
  }
  
  validates_with_method :type, :method =&gt; :valid_type?
  
  def valid_type?
    if TYPES.key? self.type.to_i
      true
    else
      [false, &quot;Invalid action type.&quot;]
    end
  end
  
  def get_type
    case TYPES[self.type]
    when &quot;Work&quot;
      &quot;you're working&quot;
    when &quot;Arena&quot;
      &quot;in the arena&quot;
    when &quot;Quest&quot;
      &quot;in a quest&quot;
    end
  end
  
   belongs_to :player
  end
  </code></pre>