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

Strip Leading & Trailing Whitespace Before Searching #1115

Closed
sshaw opened this issue Apr 5, 2020 · 1 comment · Fixed by #1126
Closed

Strip Leading & Trailing Whitespace Before Searching #1115

sshaw opened this issue Apr 5, 2020 · 1 comment · Fixed by #1126

Comments

@sshaw
Copy link

sshaw commented Apr 5, 2020

Would be very helpful to have this as a default.

@itsalongstory
Copy link
Contributor

Or, you can define a query_params method in your application_controller.rb like this:

class ApplicationController < ActionController::Base
  def query_params
    params[:q]&.each_value(&:strip!)
  end
end

And search like this:

@users = User.ransack(query_params)

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 a pull request may close this issue.

2 participants