Still having issues with helper inheritance
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
Description
I thought this was supposed to be fixed with #1665, but I am still having issues with it. I have a few classes inheriting from Grape::API and I want to avoid having to include the helpers in every endpoint class:
require "#{Rails.root}/app/api/v2/helpers/authentication_helper.rb"
module API
module V2
class Base < Grape::API
prefix 'v2'
format :json
end
class AuthenticatedBase < Base
helpers ApiHelpers::AuthenticationHelper
before { authenticate! }
end
class AdminBase < Base
# other things in here for higher security routes
end
end
end
However, when I go to make my end point class inherit, I can't use the AuthenticationHelper methods like current_user, for example.
require "#{Rails.root}/app/api/v2/base_classes.rb"
module API
module V2
class Sensors < AuthenticatedBase
desc 'End-points for Sensors'
namespace :sensors do
...
Is this intended? What am I missing?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with app/api/v2/base_classes.rb and app/api/v2/helpers/authentication_helper.rb, then inspect the API::V2::Sensors entry point and reproduce access to current_user through AuthenticatedBase. Done means the intended inheritance behavior is established and the endpoint either receives the helper methods as expected or the missing behavior is clearly documented with coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100