instance method
to_fs
Ruby on Rails 7.2.3
Since v7.0.10Signature
to_fs(format = :default)
Extends Array#to_s to convert a collection of elements into a comma separated id list if :db argument is given as the format.
This method is aliased to to_formatted_s.
Blog.all.to_fs(:db) # => "1,2,3" Blog.none.to_fs(:db) # => "null" [1,2].to_fs # => "[1, 2]"
Parameters
-
formatopt = :default
Source
# File activesupport/lib/active_support/core_ext/array/conversions.rb, line 94
def to_fs(format = :default)
case format
when :db
if empty?
"null"
else
collect(&:id).join(",")
end
else
to_s
end
end
Defined in activesupport/lib/active_support/core_ext/array/conversions.rb line 94
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Array