samsinite / filter_me Goto Github PK
View Code? Open in Web Editor NEWA Rails/ActiveRecord filtering gem
License: MIT License
A Rails/ActiveRecord filtering gem
License: MIT License
Write a rails generator that can be used to generate a filter.
Write better documentation explaining both basic filtering features better and explaining how to implement advanced filtering features.
Not sure if I did not set it up correctly. But I failed to get the expected result set from self-referential association.
I have a Category model, which has many sub-categories:
class Category < ActiveRecord::Base
belongs_to :parent_category, class_name: :Category
has_many :child_categories, class_name: :Category, foreign_key: "parent_category_id"
end
Then in my filter class:
class CategoriesFilter < FilterMe::ActiveRecordFilter
model Category
association :parent_category, filter_class: CategoriesFilter
field :name, [:eq]
end
Then when I do the filter with the following filter params:
{ filters: { parent_category: { name: { eq: "Category 1" } } } }
But this generates the following SQL query:
SELECT "categories".* FROM "categories"
INNER JOIN "categories" "parent_categories_categories"
ON "parent_categories_categories"."id" = "categories"."parent_category_id"
WHERE "categories"."name" = 'Category 1'
Guess the WHERE clause should be "parent_categories_categories"."name" instead of "categories"."name".
Any idea?
Currently trying to use one of Arel's grouping predications for a filter fails. These Arel predications should be supported. http://rdoc.info/github/rails/arel/master/Arel/Predications
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.