-
-
Notifications
You must be signed in to change notification settings - Fork 813
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
Missing/empty attribute_fields. Regression introduced with 235eae3. #701
Comments
if we have form and I want to build dynamic search using code below
I'm receiving an empty string instead of select (in version 1.7 of this gem this code was working). Quick investigation showed me that this code
|
I also am having the same issue described by the OP. The issue is present even on Rails version 4 using Ransack v 1.8.0. If I downgrade the Ransack gem to version 1.7.0 it appears to work properly again. |
Just a little bit of additional information because this impacted me as well. I have some time to take a look at this today. I'll start with 235eae3 because it appears to be the first commit that breaks the functionality You can test using the advanced search feature on an updated ransack search demo. All commits that I sampled after the commit above are missing the dropdown per the screenshot |
The attributes aren't being added, I think, because this line always seems to return false for It doesn't appear in the commits prior that the I put together a new branch and a corresponding demo branch which appear to be functional. All tests are still passing and I haven't seen any other issues/bugs. I'm not comfortable submitting a PR with this because I'm not fully familiar with the codebase but it's only a single line modified so shouldn't take too much time to look at and see if this is the fix, or if the binding/bound method should be looked at. I only tested against the ransack demo, using ActiveRecord, not mongoid. |
@jaydorsey I gave your fix a try in my app and it seems to work fine for my app as well. |
Thanks everyone for the combined info. The takeaway is that we are missing tests for this behavior. In the meantime, @jaydorsey would you like to make a PR for your patch? It is true that it doesn't break any tests, though we are missing some here. Following which, we'll release Ransack 1.8.1 as a patch release while solving it correctly. TODOs:
|
@jaydorsey, @haslinger has also updated ransack_demo (to Rails 5, perfect). Would you two like to coordinate on making PRs to update it? It looks like some of your work is complementary. |
@jonatack I don't think that PR is correct. It's simply commenting "if valid?" line which may cause other problems. I believe real fix will require more efforts. |
@igorkasyanchuk I agree. To work on this, we need tests in place first. This bug slipped through because I don't use this feature and perhaps @avit (who did the work on #645) doesn't either and the test suite passed. |
@igorkasyanchuk Would you like to make a PR that adds the missing tests? |
I didn't submit a PR because it wasn't clear what the valid check was checking. The last functional version I noted above didn't actually appear to use the valid check but I didn't test it comprehensively. I agree with @igorkasyanchuk that there could be unknown side effects. I'll reach out to @haslinger re: getting the demo updated on his repo |
@jonatack , @jaydorsey created pull request for the demo app activerecord-hackery/ransack_demo#11. |
I still have this issue with rails 3.2.22.2 and mongoid 3.1.1. Using ransack 1.7.0 works, attributes are there. But with 1.8.0 or 1.8.1 attributes are nil. |
Hi everyone, no one has added a test as mentioned above. Here's the deal: If someone cares enough to provide passing/failing regression tests to cover this, then I'm willing to look at the bug. This is open-source software and everyone can contribute ;) @rutte, when accepting addition of the Mongoid adapter, I stipulated that I don't use Mongoid and maintain its Ransack adapter. Anything Mongoid-related is up to the community. |
I'm trying to add spec, and I did following
but I'm receiving an empty string. Not sure how I can generate html. I used version 1.7.0 (I just took commit from history from 2015). Also I've tried to do following: |
Everybody, please chime in if the issue is resolved and Ransack is working correctly for you with this? Use Ransack master: If yes, will make a release with the fix. We still need test coverage for this behavior 😬 if anyone would like to chip in. |
Yes fixes it for me => PR for ransack-demo is coming in a minute. |
Great 👍. Yes, I'm overhauling ransack-demo right now. Will deploy an updated version to Heroku soon. |
See the comments in the code for more information. TODO: Add test coverage for this.
I updated one of my applications using ransack to Rails 5 and found, that the attribute_fields method returns an empty string.
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.
To reproduce the issue easily, I did the same with the ransack_demo app and found the same issue there - see Issue activerecord-hackery/ransack_demo#10.
The text was updated successfully, but these errors were encountered: