Sha256: 3a700f6777eb9a52b011c12a3fc01bc9491fcd39228f8907e7814a437f1d3632
Contents?: true
Size: 605 Bytes
Versions: 3
Compression:
Stored size: 605 Bytes
Contents
module RailsExample class Artist < ApplicationRecord scope :by_name, lambda { |name| where('lower(name) like ?', "%#{name.downcase}%") } def self.search_genre(genre) where('lower(genre) like ?', "%#{genre.downcase}%") end extend Rack::Reducer reduces all, filters: [ # filters can call class methods... ->(genre:) { search_genre(genre) }, # or scopes... ->(name:) { by_name(name) }, # or inline ActiveRecord queries ->(order:) { order(order.to_sym) }, ->(releases: ) { where(release_count: releases.to_i) }, ] end end
Version data entries
3 entries across 3 versions & 1 rubygems