activerecord-hackery / ransack_demo Goto Github PK
View Code? Open in Web Editor NEWA demo app using Ransack to create advanced search forms.
Home Page: http://ransack-demo.herokuapp.com
A demo app using Ransack to create advanced search forms.
Home Page: http://ransack-demo.herokuapp.com
Hi hackery team,
Is it possible to use this advanced search style, but offering a select field for associations? I was thinking on something like displaying the available cities if you want to filter by city. This way, we would avoid selecting "city > name > contains > text"
Thanks!
Just more an FYI, that the demo page is not working anymore, after heroku has removed the free version of their service.
On the heroku demo it displays Condition Groups > Match (all | any) conditions [remove] > Condition [remove].
I cloned the project to my machine and start the demo. For some reason the most inner 'Condition ' tag does not appear. Instead there is only the remove button and not both 'Condition [remove]'.
I've looked into the partials and javascript but can't seem to find why it is not appearing.
Any help is appreciated.
Thanks
EDIT: basically all you have to do is concatenate a string to the helper function.
<%= content_tag(:legend, "Condition " + button_to_remove_fields('remove', f),
nil, false) %>
Hi,
very good work.
Coan you explain a method to integrate search on tags?
Best regards
s
When i search for "TOM" i get 3 times Tom West, i think that the error is in the sql join, it is not necessary because we need only users.
SQL: SELECT "users".* FROM "users" LEFT OUTER JOIN "posts" ON "posts"."user_id" = "users"."id" WHERE (("users"."first_name" ILIKE '%tom%' OR "users"."last_name" ILIKE '%tom%'))
Your first 10 results
Id First name Last name Email
10 Tom West [email protected]
10 Tom West [email protected]
10 Tom West [email protected]
in order to get a better understanding of ransack, I forked it and split the demo in 2 parts, ransack_simple_demo and ransack_advanced_demo . You can get a copy the simple at https://github.com/erwin/ransack_simple_demo
I moved to MySQL and added the Twitter-Bootstrap framework.. also updated the gem file ( Machinist 2 for db:seed) and added will_paginate
I have question about it :
when I search on user parameters and post parameter, ( non distinct) I get the following generated sql :
SELECT users
.* FROM users
LEFT OUTER JOIN posts
ON posts
.user_id
= users
.id
WHERE (posts
.title
LIKE '%pa%') ORDER BY users
.last_name
ASC LIMIT 10 OFFSET 0
is there a way to display an additional column with the number of filtered posts for each listed user... ? this is possible in pure SQL, using COUNT and GROUP BY ...
SELECT users.*, COUNT(posts.id) FROM users LEFT OUTER JOIN posts ON posts.user_id = users.id WHERE (posts.title LIKE '%pa%') GROUP BY users.id ORDER BY users.last_name ASC LIMIT 10 OFFSET 0;
but how to do it using ransack ?
thanks for feedback
I notice that the demo app in Heroku uses the .live() function while the code in got uses .on(). Any idea why this difference in jQuery versions?
Also, because of the Gemfile.lock, is there a possibility this could cause a problem?
I forked the demo and updated it to ransack_demo / Rails 5.
The application itself starts, but within the condition group after adding a condition, the attribute field dropdown is missing.
I tried to debug the issue, and found that within the attribute_fields helper the call to the search_fields method returns an empty string.
In the old version (Rails 3.x) the proper html string for the dropdown was returned.
Reason for my findings is that I have exactly the same issue updating my own application to Rails 5 (so it's not specific to the demo app).
My User model has the following association: user has_many trips, through registrations.
If the search query is "Users who have gone on trip named 'ABC'", the SQL generated is fine:
SELECT DISTINCT users.* FROM users LEFT OUTER JOIN registrations ON registrations.user_id = users.id LEFT OUTER JOIN trips ON trips.id = registrations.batch_id WHERE (trips.name LIKE '%ABC%')
If the search query is "Users who have gone on trips 'ABC' and 'DEF'", how does one do it? I tried two different approaches:
SELECT DISTINCT users.* FROM users LEFT OUTER JOIN registrations ON registrations.user_id = users.id LEFT OUTER JOIN trips ON trips.id = registrations.batch_id WHERE ((trips.name LIKE '%ABC%' AND trips.name LIKE '%DEF%'))
SELECT DISTINCT users.* FROM users LEFT OUTER JOIN registrations ON registrations.user_id = users.id LEFT OUTER JOIN trips ON trips.id = registrations.batch_id WHERE ((trips.name LIKE '%ABC%' OR trips.name LIKE '%DEF%'))
The 2nd query results were those users who had either gone on ABC or DEF.
To add to this, we wanted this query: "Users who have gone on ABC but not on DEF". I tried this with two conditions (matches all): trip.name = ABC and trips.name not like DEF. This was the SQL generated:
SELECT DISTINCT users.* FROM users LEFT OUTER JOIN registrations ON registrations.user_id = users.id LEFT OUTER JOIN trips ON trips.id = registrations.batch_id WHERE ((trips.name LIKE '%ABC%' AND trips.name NOT LIKE '%DEF%'))
The above query isn't right. How does one get the right query using Ransack?
Hi @ernie, I propose to deploy an updated version of the ransack demo to heroku soon, with a slightly-nicer skin and auto-updating results, running on Rails 5 and hopefully a couple of bugs resolved as well. If you're fine with that, would you send me the heroku deploy credentials? Another possibility is that I could create a new ransack_demo heroku app. Let me know :) Cheers.
Let's refresh this design using TailwindUI.
This occurs when using the 'Add Value' functionality.
For example:
Field | Value | Value
First_name | Fern | Aric
When I click search it just refreshes the page back to default.
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.