Project

toller

0.0
Low commit activity in last 3 years
A long-lived project that still receives updates
Toller is a Rails engine that lets controllers declare filter_on/sort_on directives, then applies whichever filters and sorts are active for the current request to an ActiveRecord relation based on URL query parameters.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 6.0
 Project Readme

Toller

URL-query-param-based filtering and sorting for Rails controllers.

Toller is a Rails engine that lets controllers declare filter_on/sort_on directives, then applies whichever filters and sorts are active for the current request to an ActiveRecord relation based on URL query parameters.

See the wiki for usage information.

Requirements

  • Ruby >= 3.3.0
  • Rails >= 6.0

Installation

Add this line to your application's Gemfile:

gem 'toller', '~> 1.2'

And then execute:

$ bundle install

Filtering

Filters are not automagically set up for you. You define the filters you want.

Filtering parameters are passed in the URL as such ?filters[visible]=1. Multiple filter parameters can be passed like so ?filters[visible]=1&filters[published_after]=2020-07-04.

More information is available in the wiki.

Sorting

Sorting is not automagically set up for you. You define the sorting you want.

Sorting parameters are passed in the URL as such ?sort=position. Multiple sort parameters can be passed like so ?sort=-published_at,title.

More information is available in the wiki.

Testing

$ bin/test

Appraisal

Uses Appraisal2 (a maintained fork of Appraisal, still exposing the appraisal executable) to ensure various dependency versions work as expected

When dependencies change, run

$ bundle exec appraisal install
$ bundle exec appraisal generate-install

To run tests with Appraisal, run

$ bundle exec appraisal rspec

Without any flags, Appraisal2 defaults to running 2 appraisals in parallel. The test database is in-memory (database: ":memory:"), so each appraisal subprocess gets its own isolated database and parallel runs don't conflict. Pass -n 1 to force one Rails version at a time instead.

$ bundle exec appraisal rails-6-0 rspec
$ bundle exec appraisal rails-6-1 rspec
$ bundle exec appraisal rails-7-0 rspec
$ bundle exec appraisal rails-7-1 rspec
$ bundle exec appraisal rails-7-2 rspec
$ bundle exec appraisal rails-8-0 rspec
$ bundle exec appraisal rails-8-1 rspec

Release

See Release.md

Code Analysis

Various tools are used to ensure code is linted and formatted correctly.

RuboCop

RuboCop is a Ruby static code analyzer.

$ rubocop

YARD-Lint

YARD-Lint is a linter for YARD documentation.

$ bundle exec yard-lint

Documentation

Yard is used to generate documentation. Online documentation is available

Build the documentation with one of the following

$ yard
$ yard doc

Build the documentation and list all undocumented objects

$ yard stats --list-undoc

Contributing

  1. Fork it (https://github.com/dfrerksen/toller/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

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