For search forms, it is desireable to use a simple syntax for
searching ranges.
In a view, I would like to be able to f.select :age,
["18..21","21..28","25..35","35..108"].map{|a|[a,a]}
and in the controller i would LIKE: Person.find(:all,
:conditions=>{:age=>params[:person][:age]})
vs (I currently do): Person.find(:all,
:conditions=>{:age=>extract_age_range(params[:person][:age])})
def extract_age_range(string); Range.new( ...stuff...)
end
To pass ranges of this form through to the finders is messy; I
either need to hack rails AR::Base, or alternatively add a
controller method to match and translate these strings into
ranges.
Making finder ranges(from some string convention) default
supports restful design, and the overhead on finders is low. (an
iteration of matching through the conditions hash)
This is my first patch, so I'm looking for feedback. Should this
actually be a gem? Can do. Is my testing off-base? Happy to
change.