Prev | Current Page 499 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"


An Account object with a last_name attribute would return true to account.respond_to?
("last_name"), account.respond_to?("last_name="), and account.respond_to?("last_name?").
save()
Save the current Active Record object with this method. If the object has not yet been saved,
a new record is created in the database. If the object already has a corresponding database
record, that record is updated with the current values of this object??™s attributes. If the object
has been marked as read only, this method will raise a ReadOnlyRecord exception. If the save
was successful, this method will return true; otherwise, it will return false.
By default, Active Record mixes in the Validation module, which overrides the default
implementation of this method with the ActiveRecord::Validations.save_with_validation
method. This method takes in a Boolean value that indicates whether validations should be
run, the default of which is to run validations. Therefore, the default behavior of this method
is to trigger validations before the object is saved.


Pages:
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511