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

search_field don't preserve values between requests for alias #916

Open
fidalgo opened this issue May 3, 2018 · 6 comments
Open

search_field don't preserve values between requests for alias #916

fidalgo opened this issue May 3, 2018 · 6 comments

Comments

@fidalgo
Copy link

fidalgo commented May 3, 2018

Hi!
First of all thanks for your work 🎉

I'm using the ransack (1.8.8) with a Rails 5.1 and Ruby 2.4.3 with the following code:

Ransack alias:
ransack_alias :quick_search, :sequence_or_order_customer_name_or_order_customer_vat_identification_or_order_line_items_description

and this form:

        <%= f.search_field :quick_search_cont, value: params.dig(:q, :quick_search_cont), class: "form-control"%>
        <span class="input-group-btn">
          <%= button_tag type: :search, class: 'btn btn-primary' do %>
            <%= t('actions.search') %>
            <span class="fas fa-search"></span>
          <% end %>
        </span>
......
    <% end %>

and I need to add value: params.dig(:q, :FIELD_NAME) to every search_field in my form, to have the values binded in the form, ie, when the results are returned and the page rendered I have the search input value filled.

Where is an url example:
http://localhost:3000/invoices?utf8=%E2%9C%93&q%5Bquick_search_cont%5D=&button=&q%5Binvoice_search_cont%5D=&q%5Bperson_cont%5D=dias&q%5Bproduct_search_cont%5D=

Am I doing something wrong or there is a bug in the gem?

@supairish
Copy link

I'm seeing this also

@gregmolnar
Copy link
Member

gregmolnar commented Dec 7, 2018

@fidalgo @supairish Do you see this on 2.1.1 too?

@supairish
Copy link

@gregmolnar I'm not sure, i'm linking to master in our Gemfile. I'll see if i have time today to try 2.1.1

@jean-francois-labbe
Copy link

I see this too with 2.1.1

@teoulas
Copy link

teoulas commented Jan 24, 2020

2.3.0 also has the same bug:

class SomeModel < ActiveRecord::Base
  ransack_alias :abc, :name_or_address_or_something_else
end

r = SomeModel.ransack({abc_cont: "xyz"})
r.abc_cont
# => nil
r.name_or_address_or_something_else_cont
# => "xyz"

@mike-northsail
Copy link

This is still an issue on latest master

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

No branches or pull requests

6 participants