attribute_missing

attribute_missing(match, *args, &block) Instance Public methods attribute_missing is like method_missing, but for attributes. When method_missing is called we check to see if there is a matching attribute method. If so, we tell attribute_missing to dispatch the attribute. This method can be overloaded to customize the behavior.

load_schema

load_schema() Instance Public methods

presence

presence() Instance Public methods Returns the receiver if it's present otherwise returns nil. object.presence is equivalent to object.present? ? object : nil For example, something like state = params[:state] if params[:state].present? country = params[:country] if params[:country].present? region = state || country || 'US' becomes region = params[:state].presence || params[:country].presence || 'US' @return [Object]

advance

advance(options) Instance Public methods Uses Date to provide precise Time calculations for years, months, and days according to the proleptic Gregorian calendar. The options parameter takes a hash with any of these keys: :years, :months, :weeks, :days, :hours, :minutes, :seconds.

validate

validate() Instance Public methods

rename_column_indexes

rename_column_indexes(table_name, column_name, new_column_name) Instance Protected methods

seconds

seconds() Instance Public methods Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years. These methods use Time#advance for precise date calculations when using #from_now, ago, etc. as well as adding or subtracting their results from a Time object. For example: # equivalent to Time.current.advance(months: 1) 1.month.from_now # equivalent to Time.current.advance(years: 2) 2.years.from_now # equivalent to Time.current.advance(months: 4, years: 5

primary_key=

primary_key=(value) Instance Public methods Sets the name of the primary key column. class Project < ActiveRecord::Base self.primary_key = 'sysid' end You can also define the primary_key method yourself: class Project < ActiveRecord::Base def self.primary_key 'foo_' + super end end Project.primary_key # => "foo_id"

find_each

find_each(options = {}) Instance Public methods Looping through a collection of records from the database (using the all method, for example) is very inefficient since it will try to instantiate all the objects at once. In that case, batch processing methods allow you to work with the records in batches, thereby greatly reducing memory consumption. The find_each method uses find_in_batches with a batch size of 1000 (or as specified by the :batch_size option). Person.find_each do |p

new

new(*) Class Public methods