blob: 6e0c3b6b9cf5d38ad715bf3e140d4557114676d2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
|
module Enumerable
# Returns a JSON string representing the enumerable. Any +options+
# given will be passed on to its elements. For example:
#
# users = User.find(:all)
# # => users.to_json(:only => :name)
#
# will pass the <tt>:only => :name</tt> option to each user.
def rails_to_json(options = nil) #:nodoc:
"[#{map { |value| ActiveSupport::JSON.encode(value, options) } * ','}]"
end
end
|