delete

delete() Instance Public methods Deletes the record in the database and freezes this instance to reflect that no changes should be made (since they can't be persisted). Returns the frozen instance. The row is simply removed with an SQL DELETE statement on the record's primary key, and no callbacks are executed. To enforce the object's before_destroy and after_destroy callbacks or any :dependent association options, use #destroy.

decrement!

decrement!(attribute, by = 1) Instance Public methods Wrapper around decrement that saves the record. This method differs from its non-bang version in that it passes through the attribute setter. Saving is not subjected to validation checks. Returns true if the record could be saved.

decrement

decrement(attribute, by = 1) Instance Public methods Initializes attribute to zero if nil and subtracts the value passed as by (default is 1). The decrement is performed directly on the underlying attribute, no setter is invoked. Only makes sense for number-based attributes. Returns self.

becomes!

becomes!(klass) Instance Public methods Wrapper around becomes that also changes the instance's sti column value. This is especially useful if you want to persist the changed class in your database. Note: The old instance's sti column value will be changed too, as both objects share the same set of attributes.

becomes

becomes(klass) Instance Public methods Returns an instance of the specified klass with the attributes of the current record. This is mostly useful in relation to single-table inheritance structures where you want a subclass to appear as the superclass. This can be used along with record identification in Action Pack to allow, say, Client < Company to do something like render partial: @client.becomes(Company) to render that instance using the companies/company partial instead of

instantiate

instantiate(attributes, column_types = {}) Instance Public methods Given an attributes hash, instantiate returns a new instance of the appropriate class. Accepts only keys as strings. For example, Post.all may return Comments, Messages, and Emails by storing the record's subclass in a type attribute. By calling instantiate instead of new, finder methods ensure they get new instances of the appropriate class for each record. See +ActiveRecord::Inheritance#discriminate_class_for_reco

create

create(attributes = nil, &block) Instance Public methods Creates an object (or multiple objects) and saves it to the database, if validations pass. The resulting object is returned whether the object was saved successfully to the database or not. The attributes parameter can be either a Hash or an Array of Hashes. These Hashes describe the attributes on the objects that are to be created. Examples # Create a single new object User.create(first_name: 'Jamie') # Create an Array

touch

touch(*) Instance Public methods

no_touching?

no_touching?() Instance Public methods

no_touching

no_touching(&block) Instance Public methods Lets you selectively disable calls to `touch` for the duration of a block. Examples ActiveRecord::Base.no_touching do Project.first.touch # does nothing Message.first.touch # does nothing end Project.no_touching do Project.first.touch # does nothing Message.first.touch # works, but does not touch the associated project end