def contains(opts, *rest)
      build_where_chain(opts, rest) do |arel|
        case arel
        when Arel::Nodes::In, Arel::Nodes::Equality
          column = left_column(arel) || column_from_association(arel)

          if [:hstore, :jsonb].include?(column.type)
            Arel::Nodes::ContainsHStore.new(arel.left, arel.right)
          elsif column.try(:array)
            Arel::Nodes::ContainsArray.new(arel.left, arel.right)
          else
            raise ArgumentError, "Invalid argument for .where.contains(), got #{arel.class}"
          end
        else
          raise ArgumentError, "Invalid argument for .where.contains(), got #{arel.class}"
        end
      end
    end
def contains(opts, *rest)
      build_where_chain(opts, rest) do |arel|
        case arel
        when Arel::Nodes::In, Arel::Nodes::Equality
          column = left_column(arel) || column_from_association(arel)

          if [:hstore, :jsonb].include?(column.type)
            Arel::Nodes::ContainsHStore.new(arel.left, arel.right)
          elsif column.try(:array)
            Arel::Nodes::ContainsArray.new(arel.left, arel.right)
          else
            raise ArgumentError, "Invalid argument for .where.contains(), got #{arel.class}"
          end
        else
          raise ArgumentError, "Invalid argument for .where.contains(), got #{arel.class}"
        end
      end
    end
Finds Records that contains a nested set elements

 Array Column Type:
   User.where.contains(tags: [1, 3])
   # SELECT user.* FROM user WHERE user.tags @> {1,3}

 HStore Column Type:
   User.where.contains(data: { nickname: 'chainer' })
   # SELECT user.* FROM user WHERE user.data @> 'nickname' => 'chainer'

 JSONB Column Type:
   User.where.contains(data: { nickname: 'chainer' })
   # SELECT user.* FROM user WHERE user.data @> {'nickname': 'chainer'}

 This can also be used along side joined tables

 JSONB Column Type Example:
   Tag.joins(:user).where.contains(user: { data: { nickname: 'chainer' } })
   # SELECT tags.* FROM tags INNER JOIN user on user.id = tags.user_id WHERE user.data @> { nickname: 'chainer' }