new 2

new(*args, &block) Instance Public methods Initializes new record from relation while maintaining the current scope. Expects arguments in the same format as Base.new. users = User.where(name: 'DHH') user = users.new # => #<User id: nil, name: "DHH", created_at: nil, updated_at: nil> You can also pass a block to new with the new record as argument: user = users.new { |user| user.name = 'Oscar' } user.name # => Oscar build

pretty_print

pretty_print(q) Instance Public methods

reload

reload() Instance Public methods Forces reloading of relation.

reset

reset() Instance Public methods

scope_for_create

scope_for_create() Instance Public methods

scoping

scoping() Instance Public methods Scope all queries to the current scope. Comment.where(post_id: 1).scoping do Comment.first end # => SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = 1 ORDER BY "comments"."id" ASC LIMIT 1 Please check unscoped if you want to remove all previous scopes (including the default_scope) during the execution of a block.

size

size() Instance Public methods Returns size of the records.

to_a

to_a() Instance Public methods Converts relation objects to Array.

to_sql

to_sql() Instance Public methods Returns sql statement for the relation. User.where(name: 'Oscar').to_sql # => SELECT "users".* FROM "users" WHERE "users"."name" = 'Oscar'

uniq_value

uniq_value() Instance Public methods uniq and uniq! are silently deprecated. uniq_value delegates to distinct_value to maintain backwards compatibility. Use distinct_value instead.