Sha256: 0492acf7cc6a9938e05c61dff5815f2fb6c6b2edc0fca477bdb90eb3ae1dc6a7
Contents?: true
Size: 370 Bytes
Versions: 2
Compression:
Stored size: 370 Bytes
Contents
module FindWithOrder module MysqlSupport def self.find_with_order(relation, ids) return relation.where(id: ids).order("field(#{relation.table_name}.id, #{ids.join(',')})").to_a end def self.where_with_order(relation, column, ids) return relation.where(column => ids).order("field(#{column}, #{ids.map(&:inspect).join(',')})") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
find_with_order-1.1.1 | lib/find_with_order/mysql_support.rb |
find_with_order-1.1.0 | lib/find_with_order/mysql_support.rb |