method

as_json

as_json(options = nil)
public

No documentation available.

# File activerecord/lib/active_record/relation.rb, line 196
    def as_json(options = nil) #:nodoc:
      to_a.as_json(options)
    end

1Note

Effectively identical to Hash#as_json

SirRamonGabriel ยท Dec 20, 2017

As of 5.2.0.beta, there is no ActiveRecord::Relation specific implementation. This will result in Object#as_json , which will convert the relation to a hash and call Hash#as_json .

class Object
def as_json(options = nil) #:nodoc:
  if respond_to?(:to_hash)
    to_hash.as_json(options)
  else
    instance_values.as_json(options)
  end
end
end