All Projects → 8parth → make_model_searchable

8parth / make_model_searchable

Licence: MIT, MIT licenses found Licenses found MIT LICENSE MIT LICENSE.txt
Adds simlpe search functionality to models

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to make model searchable

log-symbols
A ruby 💎gem💎 for generating log symbols
Stars: ✭ 14 (-48.15%)
Mutual labels:  ruby-gem, gem
Unimidi
Realtime MIDI IO for Ruby
Stars: ✭ 229 (+748.15%)
Mutual labels:  ruby-gem, gem
Stitches
Create a Microservice in Rails with minimal ceremony
Stars: ✭ 371 (+1274.07%)
Mutual labels:  ruby-gem, gem
rails cursor pagination
Add cursor pagination to your ActiveRecord backed application
Stars: ✭ 21 (-22.22%)
Mutual labels:  ruby-gem, gem
pixitar
🧝 Pixitar is an avatar generation library written in Ruby.
Stars: ✭ 20 (-25.93%)
Mutual labels:  ruby-gem, gem
rspec n
A ruby gem that runs RSpec N times.
Stars: ✭ 37 (+37.04%)
Mutual labels:  ruby-gem, gem
Motion
Reactive frontend UI components for Rails in pure Ruby
Stars: ✭ 498 (+1744.44%)
Mutual labels:  ruby-gem, gem
filtered
Filters ActiveRecord queries in a nice way
Stars: ✭ 28 (+3.7%)
Mutual labels:  ruby-gem, gem
multi-tenancy-devise
mtdevise adds basecamp style user logins to your ruby on rails application.
Stars: ✭ 27 (+0%)
Mutual labels:  ruby-gem, gem
memo wise
The wise choice for Ruby memoization
Stars: ✭ 486 (+1700%)
Mutual labels:  ruby-gem, gem
jsonapi-serializer-formats
💎 Gem to enrich jsonapi-serializer with multiple formats
Stars: ✭ 20 (-25.93%)
Mutual labels:  ruby-gem, gem
churnalizer
Analyze your Ruby app for Churn vs Complexity
Stars: ✭ 17 (-37.04%)
Mutual labels:  ruby-gem, gem
Devise masquerade
Extension for devise, enable login as functionality. Add link to the masquerade_path(resource) and use it.
Stars: ✭ 380 (+1307.41%)
Mutual labels:  ruby-gem, gem
Api Fuzzer
API Fuzzer which allows to fuzz request attributes using common pentesting techniques and lists vulnerabilities
Stars: ✭ 238 (+781.48%)
Mutual labels:  ruby-gem, gem
grape-jwt-authentication
A reusable Grape JWT authentication concern
Stars: ✭ 31 (+14.81%)
Mutual labels:  ruby-gem, gem
syobocal
Simle gem for Syboi Calendar
Stars: ✭ 13 (-51.85%)
Mutual labels:  ruby-gem, gem
als typograf
Ruby client for ArtLebedevStudio.RemoteTypograf Web Service.
Stars: ✭ 15 (-44.44%)
Mutual labels:  gem
ethereal-jekyll-theme
A Jekyll version of the "Ethereal" theme by HTML5 UP.
Stars: ✭ 13 (-51.85%)
Mutual labels:  ruby-gem
rsgem
Rootstrap way ® to generate gems
Stars: ✭ 26 (-3.7%)
Mutual labels:  gem
highlights-jekyll-theme
A Jekyll version of the "Highlights" theme by HTML5 UP.
Stars: ✭ 26 (-3.7%)
Mutual labels:  ruby-gem

MakeModelSearchable

Code Triagers Badge Code Climate Gem Version

Moduler solution to add search functionality for selected fields.

Installation

Add this line to your application's Gemfile:

gem 'make_model_searchable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install make_model_searchable

Usage

To add search functionality to a model, for example User add following line to your model.
class User < ActiveRecord::Base
  searchable_attributes :first_name, :last_name
end

Then use

def index
  User.search("something")
end

searchable_attributes line makes model searchable by adding search method to User model. Specifying attributes by :first_name, :last_name enables searching in specied fields. It is optional to specify attributes, if no attributes are specified then all attributes are searched.

To enable searching from associations, you can mention asssociation name with attributes to be searched from that association as below:

Suppose our user has many posts, then in our model

class User < ActiveRecord::Base
  has_many :posts
  searchable_attributes :name, posts: [:title]
end

or if you want to search from all text or string fields,

class User < ActiveRecord::Base
  has_many :posts
  searchable_attributes :name, posts: []
end

Then use,

def index
  User.search("something")
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/8parth/make_model_searchable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].