On Martes, 4 de Mayo de 2010 17:08:01 Atastor escribió:
> Pure speculation, as I dont have time right now to check the sources
> thoroughly: Can it be that the forced :include_blank in field_search
> selectors prevents date_selects default behaviour, i.e. :discard_xxx
> true leaves xxx set to 1? Well, speculation aside, I would like to use
> it this way (and actually set an upper and lower bound on the years of
> birth search):

Yes, discard_day sets the day using current value, but the field has no current 
value

>
> config.columns[:year_of_birth].options = { :discard_day =>
> 1, :discard_month => 1, :end_year => Date.today.year-100, :start_year
> => Date.today.year-5 }
>
> Any hint how to achieve this?

You can define a custom method to generate conditions for that column. Define a 
class method named conditions_for_year_of_birth_column:
def self.conditions_for_year_of_birth_column(column, value, like_pattern)
        [:from, :to].each do |part|
                value[part][:day] = value[part][:month] = 1 unless 
value[part][:year].blank?
        end
        self.conditions_for_datetime_type(column, value, like_pattern)
end

>
> Regards
> Michael

-- 
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en.

Reply via email to