title: rails scope "expires_within"
body: <p>Hey guys. I have a model, <code>Item</code>, which is set to "expire" in <code>created_at + 100.days</code>. I am trying to create a scope that will return the items which will expire in a supplied time, such as <code>10.days</code>.</p>
  
  <p>So far I have this:</p>
  
  <pre><code>scope :expires_within, lambda {|time| where("created_at &gt; ?", time)}
  </code></pre>
  
  <p>So that I could eventually do something like:</p>
  
  <pre><code>Item.expires_within(10.days)
  </code></pre>
  
  <p>Which would return a collection of items which expire within 10 days.</p>
  
  <p>This isn't right, I just wanted to have a skeleton of what I should have. I can't figure out if it's possible to do this through a scope or not. It seems to me like I would be able to if I had a column in the table called <code>expires_at</code>, but the problem is that I would rather not create such a column because I want the expiration time, above stated as <code>created_at + 100.days</code>, to be flexible.</p>
  
  <p>I just wanted to see if it would be possible without such a column, or if it can be done but not with a scope, I'd like to hear that possibility as well. If not, I'll go ahead and add it.</p>