Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Ransacks _all and _any requests #5465

Conversation

kewubenduben
Copy link

No description provided.

@codecov
Copy link

codecov bot commented Sep 4, 2018

Codecov Report

Merging #5465 into master will decrease coverage by <.01%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5465      +/-   ##
==========================================
- Coverage   98.95%   98.94%   -0.01%     
==========================================
  Files         294      294              
  Lines       10875    10880       +5     
==========================================
+ Hits        10761    10765       +4     
- Misses        114      115       +1
Impacted Files Coverage Δ
...ib/active_admin/resource_controller/data_access.rb 99.18% <83.33%> (-0.82%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac5481c...e8bcee6. Read the comment docs.

@varyonic
Copy link
Contributor

varyonic commented Sep 4, 2018

Needs tests?

@kewubenduben
Copy link
Author

I'm kinda new into writing test code. I'm not sure on where to start.

Anyway, I'll try to write a test. And any help would be appreciated.

@varyonic
Copy link
Contributor

Related #5457

@deivid-rodriguez
Copy link
Member

@kewubenduben Can you explain a bit how you plan to use this feature? From looking at the implementation, I'm guessing you want to do something like

filter :name, filters: [:cont_any]

and then the user specifies in the text box each of the keywords she wants to match separated by spaces?

@kewubenduben
Copy link
Author

kewubenduben commented Oct 15, 2018

@deivid-rodriguez

Yes correct, I wanted the keyword search separated by spaces.

I've had this situation where I want to search from first_name and last_name from a single field.

filter :full_name_query_cont_any, as: :string, multiple: true, label: "Full Name"
# User Model
  ransacker :full_name_query do |parent|
    Arel::Nodes::NamedFunction.new('LOWER',
      [Arel::Nodes::NamedFunction.new('concat_ws',
        [Arel::Nodes::SqlLiteral.new("' '"), parent.table[:first_name], parent.table[:last_name]])])
  end

This is for example.

first_name = 'Black Hawk'
last_name = 'Down Under'

Searching for black under would return any of the names(first and last) that contains black or under. Instead of only matching for 'black under'.

I understand that this works with tags too, but tags look a bit ugly on doing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants