I have a table without an ID column. When I try to delete from it using ActiveRecord the generated SQL is DELETE FROM table_name WHERE ID=NULL, which obviously doesn’t work. Is there any way to delete from the table using ActiveRecord, or at least run a raw SQL delete query with placeholders (so it’s not vulnerable to SQL injection)?
I have a table without an ID column. When I try to delete from
Share
Have you tried using ActiveRecord’s delete_all method? Here’s an excerpt in a sandbox of mine:
The generated SQL is
DELETE FROM `customers` WHERE (`customers`.`login` = 'foo')Check out the documentation