标签: ruby-on-rails string-interpolation
我正在构建像query = "'keys.description LIKE?','desc%'" 这样的查询值,以便在活动记录查询中传递条件。
query = "'keys.description LIKE?','desc%'"
问题是当我将此值存储在字符串
Class.select.where("#{query}")
当我在查询where('keys.description LIKE ?','desc%')中插入它时,等效的sql条件就像这个where(keys.description LIKE ? desc%)而不是{{1}}。
where('keys.description LIKE ?','desc%')
where(keys.description LIKE ? desc%)