How can I subtract a variable from a date in Ruby on Rails,
example:
I want to subtract a variable, which can contain any value between 1 and 7, which represent days, from a specified date.
In algorithm it would be something like this:
días = 5
fecha = 20170602
fecha_resultado = fecha - días
date_result would have the value of:20170527
You can if you use the type
Date
that Ruby implements for these cases:This of course also works for ActiveRecord