Skip to content

Instantly share code, notes, and snippets.

@nicolaslazartekaqui
Created June 2, 2014 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolaslazartekaqui/21d863ff0f1a7dc61cab to your computer and use it in GitHub Desktop.
Save nicolaslazartekaqui/21d863ff0f1a7dc61cab to your computer and use it in GitHub Desktop.
# app/models/bar.rb
class Bar < ActiveRecord::Base
include Searchable
end
# app/models/foo.rb
class Foo < ActiveRecord::Base
include Searchable
end
# app/models/concern/searchable.rb
module Searchable
extend ActiveSupport::Concern
included do
scope :term, ->(term) do
where { name.like("%#{term}%") }
end
end
end
# spec/concerns/searchable_spec.rb
require 'spec_helper'
describe Searchable do
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment