-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Helpers are not being inherited from parent classes #1617
Comments
I think |
@dblock Cool, thanks for the confirmation. I don't know offhand how I'd go about fixing it, but I will try. |
Begin by writing a failing spec! |
Of course! I just meant I don't know what I will have to touch after said spec is written. 😄 |
@flanger001 @dblock gentlemen, I can take a look to this one if you don't mind |
Please @pablonahuelgomez ! |
That would be awesome @pablonahuelgomez - I imagine this has something to do with load order, but I'm not sure how to go about fixing it. |
@flanger001 @dblock please see #1665, it performs helpers inheritance. |
Suppose I have a
Base
class with some basic stuff I want to include in every endpoint:I have a
Root
class which inherits fromBase
, where I mount myUsers
endpoint:The
Users
endpoint also inherits fromBase
:And here's the
Show
:I would expect that the
use
statement in theShow
endpoint would work because I expect that my:user_params
helper is available, having been declared onBase
. However, it does not. In fact the whole API fails to load because of that statement.I am not sure if this is a bug, a feature, or user error, but I don't understand what's going on here. My only working solution is to put those helpers in a module that extends
Grape::API::Helpers
and include it on every single endpoint which needs that helper. In small projects this is trivial (and I probably wouldn't even bother with the helper module), but it would be very helpful to have this behavior in large projects.Edit: I made a test project illustrating this here: https://github.com/flanger001/grape_example
The text was updated successfully, but these errors were encountered: