I've actually run with the following:
def validate
errors.add('start_date', 'is not in Date format') if
!start_date.kind_of?(Date)
errors.add('end_date', 'is not in Date format') if !end_date.kind_of?(Date)
end
Its seems that the Rails controller tries to convert it to Date and
either succeeds or fails (without throwing an exception). So I just
test to see at the subsequent validate stage whether there is a Date
object or not
On Sat, Nov 22, 2008 at 5:22 AM, Rick <[EMAIL PROTECTED]> wrote:
>
> Greg,
>
> validates_inclusion_of is looking for :in to be an enumeration. In a
> simple case (one day granularity) you're asking for a list that's
> 365.25 * 200 => 73050 items long.
>
> My guess is it's a good thing it didn't work ;-)
>
> Maybe you want to go for a min/max check here.
>
> Rick
>
> On Nov 20, 11:22 am, "Greg Hauptmann" <[EMAIL PROTECTED]>
> wrote:
>> wondering if should this work? - "validates_inclusion_of :start_date,
>> :in => (Time.now.to_date - 100.years)..(Time.now.to_date + 100.years)"
>> (doesn't seem to for me)
>>
>> i.e. should I be able to "validates_inclusion_of" to do date validation.
>>
>> ................
>> class GraphOptions < ActiveRecord::BaseWithoutTable
>> column :start_date, :date
>> validates_inclusion_of :start_date, :in => (Time.now.to_date -
>> 100.years)..(Time.now.to_date + 100.years)
>> end
>> ................
>>
>> tks
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---