title: RoR | Range of Dates not traversing multiple months
body: <p>I'm trying to create an array of dates for a calendar where there are a few extra day for the next and previous month that will fill in the week.</p>
  
  <p>Here is my current method to try and get the array</p>
  
  <pre><code>def calendar
    selected_month = Date.civil((Time.zone.now.year).to_i, (Time.zone.now.month).to_i)
  
    start_date = selected_month.beginning_of_month
    start_date.sunday? ? start_date : start_date.beginning_of_week.advance(:days =&gt; -1)
  
    end_date = selected_month.end_of_month
    end_date.sunday? ? end_date.advance(:days =&gt; 1).end_of_week : end_date
  
    #only puts 1-30/31 and does not include the extra off set of days from start and end. :( 
    date_range = (start_date..end_date).to_a   
  end
  </code></pre>
  
  <p>The problem is the rang only start at 1 and goes to the end of the month even though the start and end days exceed that. </p>
  
  <p>I'm not married to this way of getting the array so maybe you have a better whole idea?</p>