title: Rails scope created within month
body: <p>I've got some issues with writing my model scope. I want to filter my model objects based on a month in which they are published, i.e model BlogPost :</p>
  
  <pre><code>scope :published_in_month, -&gt;(date) { where(published_date: date.at_beginning_of_month..date.at_end_of_month) }
  </code></pre>
  
  <p>So this is my controller method :</p>
  
  <pre><code>def list_by_month
      @date = Time.parse("#{params[:year]}/#{params[:month]}")
      puts "DATE IS #{@date}"
      @posts = BlogPost.published_in_month(@date).page(params[:page]).per(10)
      render :index
    end
  </code></pre>
  
  <p>So date printed out I see is :</p>
  
  <pre><code>DATE IS 2013-12-01 00:00:00 +0100
  </code></pre>
  
  <p>But in my log and it the page I see post(s) from wrong month, this is a entry log :</p>
  
  <pre><code>SELECT "blog_posts".* FROM "blog_posts" WHERE ("blog_posts"."published_date" BETWEEN '2013-11-30 23:00:00.000000' AND '2013-12-31 22:59:59.999999') LIMIT 10 OFFSET 0
  </code></pre>
  
  <p>Where is this <code>2013-11-30</code> coming from when my input date is <code>2013-12-01</code>, and how can I rewrite my scope if I made mistake with it to produce incorrect query</p>