cache_key

cache_key(*timestamp_names) Instance Public methods Returns a cache key that can be used to identify this record. Product.new.cache_key # => "products/new" Product.find(5).cache_key # => "products/5" (updated_at not available) Person.find(5).cache_key # => "people/5-20071224150000" (updated_at available) You can also pass a list of named timestamps, and the newest in the list will be used to generate the key: Person.find(5).cache_key(:updated_at, :last_reviewed_at)

to_param

to_param() Instance Public methods Returns a String, which Action Pack uses for constructing an URL to this object. The default implementation returns this record's id as a String, or nil if this record's unsaved. For example, suppose that you have a User model, and that you have a resources :users route. Normally, user_path will construct a path with the user object's 'id' in it: user = User.find_by(name: 'Phusion') user_path(user) # => "/users/1" You can override to_param in

column_defaults

column_defaults() Instance Public methods

locking_column

locking_column() Instance Public methods The version column used for optimistic locking. Defaults to lock_version.

locking_column=

locking_column=(value) Instance Public methods Set the column to use for optimistic locking. Defaults to lock_version.

locking_enabled?

locking_enabled?() Instance Public methods Returns true if the lock_optimistically flag is set to true (which it is, by default) and the table includes the locking_column column (defaults to lock_version).

quoted_locking_column

quoted_locking_column() Instance Public methods Quote the column name used for optimistic locking.

reset_locking_column

reset_locking_column() Instance Public methods Reset the column used for optimistic locking back to the lock_version default.

update_counters

update_counters(id, counters) Instance Public methods Make sure the lock version column gets updated when counters are updated.

lock!

lock!(lock = true) Instance Public methods Obtain a row lock on this record. Reloads the record to obtain the requested lock. Pass an SQL locking clause to append the end of the SELECT statement or pass true for âFOR UPDATEâ (the default, an exclusive row lock). Returns the locked record.