Giter VIP home page Giter VIP logo

will_filter's Introduction

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', "~> 3.1.0" 
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:

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

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

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

Screenshots

Below are a couple of screenshot of what the filter looks like when it is rendered on a page:

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 [email protected]

Authors and credits

Authors

Michael Berkovich

will_filter's People

Contributors

aziz avatar berk avatar

Watchers

James Cloos avatar Björn Nordstrand avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.