【发布时间】:2019-06-23 02:30:57
【问题描述】:
严格来说是 linting 错误,而不是功能错误 - rubocop 在我的 format_with 方法上引发了 linting 错误。它要我做format_with(:mongo_id)(&:to_s),但这在物理上是不可能的。
class Mongoid < Grape::Entity
format_with(:mongo_id) { |id| id.to_s }
expose :_id, as: :id, format_with: :mongo_id
# ...
end
以下是错误信息
Style/SymbolProc: Pass '&:to_s' as an argument to 'format_with' instead of a block.
【问题讨论】: