Giter Site home page Giter Site logo

activerecord-hackery / ransack_demo Goto Github PK

View Code? Open in Web Editor NEW
116.0 116.0 68.0 235 KB

A demo app using Ransack to create advanced search forms.

Home Page: http://ransack-demo.herokuapp.com

Ruby 76.24% JavaScript 3.62% CSS 1.39% HTML 15.15% SCSS 3.33% Procfile 0.27%

ransack_demo's People

Contributors

deivid-rodriguez avatar dependabot[bot] avatar ernie avatar flov avatar gregmolnar avatar haslinger avatar jonatack avatar radar avatar scarroll32 avatar tibastral avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ransack_demo's Issues

Select for associations

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!

Condition tag

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) %>

searching on tags

Hi,

very good work.
Coan you explain a method to integrate search on tags?

Best regards

s

duplicate results

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]

how should I proceed to display the number of filtered posts related to a user

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

jQuery version problem?

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?

Compatibility with Rails 5 - attribute_fields

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).

Filtering multiple conditions through associated objects

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:

  1. Two separate conditions with name = 'ABC' and name = 'DEF'. This was done with "matches all". The SQL gave 0 results (obviously) as this was 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 LIKE '%DEF%'))
  1. I tried "matches any" instead. That gave this:
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?

Deploy an updated version to heroku

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.

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.