next_month

next_month() Instance Public methods Short-hand for #months_since(1).

validates_presence_of

validates_presence_of(*attr_names) Instance Public methods Validates that the specified attributes are not blank (as defined by Object#blank?). Happens by default on save. class Person < ActiveRecord::Base validates_presence_of :first_name end The first_name attribute must be in the object and it cannot be blank. If you want to validate the presence of a boolean field (where the real values are true and false), you will want to use validates_inclusion_of :field_name, in: [tru

pluck

pluck(*column_names) Instance Public methods Use pluck as a shortcut to select one or more attributes without loading a bunch of records just to grab the attributes you want. Person.pluck(:name) instead of Person.all.map(&:name) Pluck returns an Array of attribute values type-casted to match the plucked column names, if they can be deduced. Plucking an SQL fragment returns String values by default. Person.pluck(:id) # SELECT people.id FROM people # => [1, 2, 3] Person.plu

unscope

unscope(*args) Instance Public methods Removes an unwanted relation that is already defined on a chain of relations. This is useful when passing around chains of relations and would like to modify the relations without reconstructing the entire chain. User.order('email DESC').unscope(:order) == User.all The method arguments are symbols which correspond to the names of the methods which should be unscoped. The valid arguments are given in VALID_UNSCOPING_VALUES. The method can also

beginning_of_quarter

beginning_of_quarter() Instance Public methods Returns a new date/time at the start of the quarter. Example: 1st January, 1st July, 1st October. DateTime objects will have a time set to 0:00. at_beginning_of_quarter

increment

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

beginning_of_month

beginning_of_month() Instance Public methods Returns a new date/time at the start of the month. DateTime objects will have a time set to 0:00. at_beginning_of_month

append_features

append_features(base) Instance Public methods

delete_entry

delete_entry(key, options) Instance Protected methods

increment!

increment!(attribute, by = 1) Instance Public methods Wrapper around increment 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.