rails active records code example
Example 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);
Example 2: 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