TODO: Write a gem description
Add this line to your application's Gemfile:
gem 'mongoid_filter'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mongoid_filter
class Log
include Mongoid::Document
include MongoidFilter
field :event_type, type: String
field :status, type: Boolean
# It will allow us to filter by this three fields
can_filter_by :event_type, :status, :created_at
# Specify custom method to create object from params
special_filter :created_at, ->(date) { Date.strptime(date, '%m/%d/%Y') }
end
@logs = Log.where(user_id: user.id).filter_by(params[:search])
<%= form_for @request_logs.filter_form_object, as: :search do |f| %>
<%= f.select :event_type_eq, Log.event_types %>
<%= f.select :status_eq, Log.statuses %>
<%= f.text_area :created_at_gt %>
<% end %>
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request