Answers for "active record create!"

0

update a database in ruby

def update
    sql = <<-SQL
    UPDATE dogs SET name = ?, breed = ? WHERE id = ?
    SQL

    DB[:conn].execute(sql, self.name, self.breed, self.id)
  end
Posted by: Guest on November-14-2019
1

active record

part = new Part()
part.name = "Sample part"
part.price = 123.45
part.save()

// will create a new row in the parts table with the given values, and is roughly equivalent to the SQL command

INSERT INTO parts (name, price) VALUES ('Sample part', 123.45);
Posted by: Guest on June-06-2020

Browse Popular Code Answers by Language