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

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(method_name = nil) Instance Public methods Defines your model's to_param method to generate Ć¢prettyĆ¢ URLs using method_name, which can be any attribute or method that responds to to_s. class User < ActiveRecord::Base to_param :name end user = User.find_by(name: 'Fancy Pants') user.id # => 123 user_path(user) # => "/users/123-fancy-pants" Values longer than 20 characters will be truncated. The value is truncated word by word. user = User.find_by(name: '

initialize_dup

initialize_dup(other) Instance Public methods

compute_type

compute_type(type_name) Instance Protected methods Returns the class type of the record using the current module as a prefix. So descendants of MyApp::Business::Account would appear as MyApp::Business::AccountSubclass.

symbolized_sti_name

symbolized_sti_name() Instance Public methods

symbolized_base_class

symbolized_base_class() Instance Public methods

sti_name

sti_name() Instance Public methods

new

new(*args, &block) Instance Public methods Determines if one of the attributes passed in is the inheritance column, and if the inheritance column is attr accessible, it initializes an instance of the given subclass instead of the base class.

descends_from_active_record?

descends_from_active_record?() Instance Public methods Returns true if this does not need STI type condition. Returns false if STI type condition needs to be applied.