ruby on rails - Why is my Model.where() returning a blank array (when I'm sure there are matches)? -


what doing incorrectly giving me blank array command?

item.where(:load_date => date.today + 2) 

here rails console:

.9.3-p194 :024 > item.first.load_date item load (0.3ms)  select "items".* "items" limit 1 => fri, 24 may 2013  1.9.3-p194 :025 > item.where(:load_date => date.today + 2) item load (0.5ms)  select "items".* "items" "items"."load_date" = '2013-05-24' => [] 1.9.3-p194 :026 > item.first.load_date == date.today + 2 item load (0.3ms)  select "items".* "items" limit 1 => true  

item model:

...  #  load_date       :date ...  class item < activerecord::base attr_accessible :bt_num, :dept, :formula, :item_code, :load_date, :prod_comments, :qc_comments, :qc_tech, :qty_in_kg, :qty_in_liters, :rm_ok_by, :series, :status, :time_to_produce, :vat ... 

try these

item.where(:load_date => (date.today + 2).strftime)   or  item.where("date(load_date) =?", (date.today + 2).strftime) 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -