find

find(*args) Instance Public methods Find by id - This can either be a specific id (1), a list of ids (1, 5, 6), or an array of ids ([5, 6, 10]). If no record can be found for all of the listed ids, then RecordNotFound will be raised. If the primary key is an integer, find by id coerces its arguments using to_i. Person.find(1) # returns the object for ID = 1 Person.find("1") # returns the object for ID = 1 Person.find("31-sarah") # returns the object for ID = 31 Pers

javascript_include_tag

javascript_include_tag(*sources) Instance Public methods Returns an HTML script tag for each of the sources provided. Sources may be paths to JavaScript files. Relative paths are assumed to be relative to assets/javascripts, full paths are assumed to be relative to the document root. Relative paths are idiomatic, use absolute paths only when needed. When passing paths, the â.jsâ extension is optional. If you do not want â.jsâ appended to the path extname: false can be set on the o

type_cast

type_cast(value) Instance Public methods

build

build(app) Instance Public methods

expires_now

expires_now() Instance Public methods Sets a HTTP 1.1 Cache-Control header of no-cache so no caching should occur by the browser or intermediate caches (like caching proxy servers).

add

add(attribute, message = :invalid, options = {}) Instance Public methods Adds message to the error messages on attribute. More than one error can be added to the same attribute. If no message is supplied, :invalid is assumed. person.errors.add(:name) # => ["is invalid"] person.errors.add(:name, 'must be implemented') # => ["is invalid", "must be implemented"] person.errors.messages # => {:name=>["must be implemented", "is invalid"]} If message is a symbol, it will be

attribute_method_suffix

attribute_method_suffix(*suffixes) Instance Public methods Declares a method available for all attributes with the given suffix. Uses method_missing and respond_to? to rewrite the method. #{attr}#{suffix}(*args, &block) to attribute#{suffix}(#{attr}, *args, &block) An attribute#{suffix} instance method must exist and accept at least the attr argument. class Person include ActiveModel::AttributeMethods attr_accessor :name attribute_method_suffix '_short?' define_a

validates_exclusion_of

validates_exclusion_of(*attr_names) Instance Public methods Validates that the value of the specified attribute is not in a particular enumerable object. class Person < ActiveRecord::Base validates_exclusion_of :username, in: %w( admin superuser ), message: "You don't belong here" validates_exclusion_of :age, in: 30..60, message: 'This site is only for under 30 and over 60' validates_exclusion_of :format, in: %w( mov avi ), message: "extension %{value} is not allowed" va

descendants

descendants(klass) Class Public methods

serialize

serialize(name, value) Instance Protected methods