ruby on rails - Date comparison for same dates -



ruby on rails - Date comparison for same dates -

my problem when user selects same dates, query below returns empty array. instead when user selects same dates, has show users created @ date. help appreciated.

user.where("created_at >= ? , created_at =< ?", params[:from].to_date, params[:to].to_date)

you using datetime database columns. problem user selects "from" (for example) 2011-07-09 , comparing database translates "2011-07-09 00:00:00" , if user selects same day twice, there no results (unless created @ "2011-07-09 00:00:00"). prepare this, do

to_date = params[to].to_date + 1.day

before making actual database search call. , utilize to_date instead of params[:to].to_date

ruby-on-rails

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -