Sam Woodard wrote:
I call admin/2006 and routes.rb sends 2006 as param[:year] to admin/list (controller/action). List then uses Day.find_by_year( params[:year] ) to find all Day records for that particular year. However, it is passing find_by_year '2006' instead of 2006 and sql is throwing an error because it is getting,
WHERE (date >= ''2006'-01-01' AND date <= ''2006'-12-31')
instead of
WHERE (date >= '2006-01-01' AND date <= '2006-12-31')
.
How do I fix it so that the routing does not put '2006' in params[:year], but rather, just 2006?
Sam
-- Posted via http://www.ruby-forum.com/.
All parameters get serialized as strings, so what you really need to do is modify your line to read something like this..
Day.find_by_year( params[:year].to_i)
This just forces the string representation of year to an integer.
_Kevin