Skip to content
lukasalexandre edited this page Dec 21, 2012 · 1 revision

To persist the data objects created in your application your can use the following methods:

Car.create( # save the new record in the database
  year: 2007,
  make: 'Chevrolet',
  model: 'F450',
  description: 'ac, abs, moon',
  price: 5000.00
)

car.save # save the record in the database (either creating or changing)

car.update_attribute :year, 1999 # update a single field of an object
car.update_attributes year: 1999, model: 'E762' # update multiple fields at the same time

car.destroy # removes the record from the database

car.new_record? # checks if the record is new
Clone this wiki locally