How to delete older records through ActiveRecord

I have a ruby script that adds records to MySql with no problem, here is
the code:

snmp_data = Snmpdatas.new(“name” => LabelDescription,
“time” => My_Time,
“inbits” => SpeedIn.to_i)
snmp_data.save

I need to be able to delete records after a certain date similar to the
sql statement:

delete * from snmp_datas where date < ‘2015-11-01’;

Any help would be appreciated.

thanks

Jack

Try this:

Snmpdatas.where(‘date < ?’, ‘2015-11-01’).delete_all

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs