-
-
Notifications
You must be signed in to change notification settings - Fork 810
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
undefined method `merge' for "search":String #1269
Comments
Would you be able to provide a reproducible example, so it can be investigated? |
@brodyhoskins I think the problem is that your second controller is misusing the "q" parameter. How are you building the form where the search input is typed? |
Closing due to lack of feedback. |
I also got the same error. My environment is: Here's how to reproduce it. controller: class ProductsController < ApplicationController
def index
@q = Product.ransack(params[:q])
@products = @q.result
end
end view: <% if @products.present? %>
<%= sort_link(@q, :id) %>
<% end %>
and access: Normally people do not access that URL, but typing the URL directly will result in an error.
|
This one was fixed by #1374 and I plan to release it very soon as Ransack 4.0. |
I'm hesitant to file an issue here but I can't seem to get to the bottom of this.
My environment is:
Rails 7.0.0
ransack (2.5.0)
ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [arm64-darwin21]
I have a controller that searches various models on the same page (see Controller B below).
In my working controllers I have:
Controller A (Working):
The non-working controller contains:
Controller B (Non-Working):
My views work by passing along the
Ransack::Search#result
result (to be paginated once I have this working) as well as theq
:But I'm running into:
I've been digging through
lib/ransack/helpers/form_helper.rb
quite a bit to debug the difference between controller A and controller B with some good old-fashionedputs
statements. Here are those results:Controller A (Working):
Controller B (Non-Working):
I've confirmed the view does indeed receive the right type of object by removing the
sort_link
and replacing it with:It outputs:
I'm not entirely sure why passing a
Ransack::Search
object in one place works as intended but in another, it doesn't. I'm using the same call tosort_link
since it's called by the same partial each time.The text was updated successfully, but these errors were encountered: