Allow type to be a model
Open
Nobody has claimed this yet.
discuss!
feature request
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
Description
I don't have an idea for the best syntax but I find myself loading models from the params hash a lot. What if you were able to do something like this?
params do
requires :user_id, identifies: User
end
get 'users/:user_id' do
params[:user] # params calls User.find internally and raises the appropriate error if nothing is found
end
Thoughts?
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
No file, test, or entry point is named. Start by reviewing how Grape parameter declarations and params access currently work, then determine the intended syntax, model lookup behavior, and error handling. Done would require an agreed API design and tests covering successful lookup and missing models.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100