Prev | Current Page 503 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

This method does not cause the Active Record object to be saved.
toggle!(attribute)
This method also sets the specified attribute to true if the current value is false and sets it to
false if the current value is true. This method does save the changed attribute to the database.
However, when the attribute is saved, the object validations are not run, allowing the
attribute to be saved even if the full object is not valid.
APPENDIX ?–  ACTIVE RECORD METHODS IN DETAIL 230
update_attribute(name, value)
This method updates the specified attribute with the specified value and saves the record. By
default, Active Record mixes in the Validation module, which overrides the default implementation
of this method with the ActiveRecord::Validations.update_attributes method.
Therefore, the default behavior of this method is to skip validations, allowing the attribute to
be saved even if the full object is not valid.
update_attributes(attributes)
This method takes in a hash with attribute names as the keys and the corresponding attribute
values as the values.


Pages:
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515