Answers for "rails destroy item from table"

5

how to delete a table in rails

rails g migration DropProducts

class DropProducts < ActiveRecord::Migration
  def change
    drop_table :products
  end
end
Posted by: Guest on February-14-2020
0

rails destroy something from db

user.destroy
User.find(15).destroy
User.destroy(15)
User.where(age: 20).destroy_all
User.destroy_all(age: 20)
Posted by: Guest on March-01-2021

Browse Popular Code Answers by Language