stas / jsonapi.rb

Lightweight, simple and maintained JSON:API support for your next Ruby HTTP API.
MIT License
261 stars 57 forks source link

Raise unless Ransack ignore_unknown_conditions? #63

Open sienic opened 3 years ago

sienic commented 3 years ago

What is the current behavior?

https://github.com/stas/jsonapi.rb/issues/62

What is the new behavior?

It allows to use the Ransack configuration property ignore_unkown_conditions with the same semantics as in Ransack. A disadvantage of this solution is that Ransack so far has been a dependency of jsonapi.rb, and not necessarily of the projects which use Jsonapi.rb. Somehow it could be considered a co-dependency of jsonapi.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:

sienic commented 3 years ago

Unfortunately, this does not work with the sort parameter (which uses the same function I modified). I will wait for further feedback on how you'd like to go about this, as there are multiple possibilities, and this issue actually might not be an issue from your point of view.

CofenseLabs-Doug commented 2 years ago

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.

sienic commented 2 years ago

@CofenseLabs-Doug 👍 @stas how about the other idea of having a way to configure jsonapi, so as to set properties for Ransack at https://github.com/stas/jsonapi.rb/blob/master/lib/jsonapi/patches.rb#L3-L6