Sha256: 4e43196e9c1bdc0a07561ba70f1dea40070dd51a678cc8fc1457992e17d13068
Contents?: true
Size: 542 Bytes
Versions: 1
Compression:
Stored size: 542 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) } ] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-reducer-0.1.1 | spec/_rails_example/app/models/rails_example/artist.rb |