method

new

rails latest stable - Class: ActiveRecord::Relation
new(attributes = nil, &block)
public

Initializes new record from relation while maintaining the current scope.

Expects arguments in the same format as ActiveRecord::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