will_filter

rails engine plugin for filtering active_record model objects

  • Owner: berk/will_filter
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

= WillFilter

will_filter is a Rails engine plugin that provides a GUI for filtering your ActiveRecord models.

== Preamble

If you ever had to build an admin tool for your web site that displayed a list of objects that can be filtered using
various criteria, this plugin will make your life easier. Adding a filtered page can now be
a matter of adding two lines of code - one to your controller and one to your view. See examples below.

== Installation Instructions

Add the following gems to your Gemfile:

gem 'will_filter'
gem 'kaminari'

And run:

$ bundle

To configure and initialize will_filter engine, run the following commands:

$ rails generate will_filter
$ rake db:migrate

At the top of your routes.rb file, add the following line:

mount WillFilter::Engine => "/will_filter"

== Examples

To add a filtered result-set to your controller use the following method call:

class UsersController < ApplicationController

def index
  @users = User.filter(:params => params)    
end

end

Note: 'User' is a Rails ActiveRecord model

Now all you have to do is create a view for this action and add the following tag where you want the filter to be rendered:

<%= will_filter_tag(@users) %>

And optionally you can do (for results table):

<%= will_filter_table_tag(@users) %>

That's it. This will render a filter box with various conditions, operators and values for the model object you selected.

= Documentation

Please read the following document to learn more about filter customization:

https://github.com/berk/will_filter/wiki/Customizing-Filters

Please read the following document to learn more about table tag customization:

https://github.com/berk/will_filter/wiki/Customizing-Table-View

= Dummy Application

This plugin comes with a dummy test project. To try out some of the examples, run the following commands:

$ git clone git://github.com/berk/will_filter.git
$ cd will_filter/test/dummy
$ rake db:migrate
$ rake samples:init
$ rails server

Open your browser and point to:

http://localhost:3000

If you have any questions, comments or suggestions, email me at theiceberk@gmail.com

== Authors and credits

Authors:: Michael Berkovich

Main metrics

Overview
Name With Ownerberk/will_filter
Primary LanguageRuby
Program languageRuby (Language Count: 4)
Platform
License:MIT License
所有者活动
Created At2009-02-27 07:15:06
Pushed At2023-01-19 05:42:15
Last Commit At2018-06-29 12:13:34
Release Count12
Last Release Name5.1.4 (Posted on )
First Release Namev3.1.2 (Posted on 2011-10-01 13:57:52)
用户参与
Stargazers Count157
Watchers Count11
Fork Count76
Commits Count158
Has Issues Enabled
Issues Count60
Issue Open Count40
Pull Requests Count5
Pull Requests Open Count12
Pull Requests Close Count15
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private