Topic: select date time.

Is there a way to make select_datetime.  only display the next 30 days worth of entries?


Re: select date time.

You can do something like:

<%= date_select('order', 'date_entered', :start_year => 2006, :end_year => 2007) %>

So it is a shame you can't just add the option :until => 30.days.from_now, so I think you will actually have to manually write this thing out.

Last edited by dahuk (2006-11-13 09:30:55)

Re: select date time.

The inherit problem with this is that displaying a drop down for the day, month, and year for the next 30 days would only leave you with one year, and a max of two months. 

Describe the business problem and we might be able to help with a more suitable solution.

Re: select date time.

I think it is better to handle this in the validation:

def validate
  errors.add(:some_date, 'needs to be within the next 30 days') if some_date > 30.days.from_now

Railscasts - Free Ruby on Rails Screencasts