You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use it in a Rails app with many models: some of them are "ransackable" (displayed with a search form) while others are not.
I know that in order to be "ransackable" a model needs to define some methods.
I can call Model.ransackable_attributes and know if the those methods are defined: if they are not, I see this RuntimeError:
Ransack needs Model attributes explicitly allowlisted as searchable.
Define a `ransackable_attributes` class method in your model…
So my way to know if a model is "ransackable" is this method:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello and thanks for this awesome library.
I use it in a Rails app with many models: some of them are "ransackable" (displayed with a search form) while others are not.
I know that in order to be "ransackable" a model needs to define some methods.
I can call
Model.ransackable_attributesand know if the those methods are defined: if they are not, I see this RuntimeError:So my way to know if a model is "ransackable" is this method:
This works but… it's not great Ruby code. I would like to know without raising and then rescuing an error.
Would you be open in having such a method implement in the ransack codebase? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions