Raise unless Ransack ignore_unknown_conditions?#63
Raise unless Ransack ignore_unknown_conditions?#63sienic wants to merge 1 commit intostas:masterfrom
Conversation
|
Unfortunately, this does not work with the sort parameter (which uses the same function I modified). |
stas
left a comment
There was a problem hiding this comment.
Btw, in the next version v1.8 Ransack will be a soft-dependency.
| end | ||
| unless predicates.present? || Ransack.options[:ignore_unknown_conditions] | ||
| raise ArgumentError, "No valid predicates for #{requested_field}" | ||
| end |
There was a problem hiding this comment.
Hmm, I think this is handled already by Ransack:
https://github.com/stas/jsonapi.rb/blob/master/lib/jsonapi/patches.rb#L6
Just reset the option in your config and it should work, no?
There was a problem hiding this comment.
@stas: It seems to be ignored, from my testing.
|
Thank you for this, @sienic. FWIW I decided to slightly slightly change your solution so that ActionController::BadRequest is raised instead of ArgumentError, resulting in a 400 response to the client instead of 500. |
|
@CofenseLabs-Doug 👍 |
What is the current behavior?
#62
What is the new behavior?
It allows to use the
Ransackconfiguration propertyignore_unkown_conditionswith the same semantics as in Ransack.A disadvantage of this solution is that
Ransackso far has been a dependency ofjsonapi.rb, and not necessarily of the projects which useJsonapi.rb. Somehow it could be considered a co-dependency ofjsonapi.rb, but that is not up to me.Another solution would be to add a configuration object to
jsonapi.rb.Checklist
Please make sure the following requirements are complete:
features)