mardi 20 novembre 2018

How to apply where condition to each record

Rails 3.22
I have a table named AccountClose in which i need to display difference of days for each record.
Here is my code

          @a = AccountClose.where("AccountCloseId is not null").last.Date.to_date
          @before = Date.today 
          @difference_in_days = (@before.to_date - @a.to_date).to_i 

Above query only displaying difference_in_days for last record only,I want to display difference_in_days for every HPId which is present in AccountClose
Could anyone help me with this?

Aucun commentaire:

Enregistrer un commentaire