JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Does Resource class always assume @model is reloadable?
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2.3k
- Forks
- 546
- PR merge metrics
- No merged PRs in 30d
Description
In Resource#save:
def _save(validation_context = nil)
unless @model.valid?(validation_context)
fail JSONAPI::Exceptions::ValidationErrors.new(self)
end
if defined? @model.save
saved = @model.save(validate: false)
unless saved
if @model.errors.present?
fail JSONAPI::Exceptions::ValidationErrors.new(self)
else
fail JSONAPI::Exceptions::SaveFailed.new
end
end
else
saved = true
end
@model.reload if @reload_needed
@reload_needed = false
@save_needed = !saved
:completed
end
We check to see if the save action exists but we don't check if the reload action exists.
Why is that? What other types of classes besides ActiveRecord::Base was this intended to work on? Or was this code only intended to work against ActiveRecord?
This is important to know as I'm refactoring for #1006 .
Contributor guide
No contributing guide indexed for this repository
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 at Resource#save, especially the @model.save and @model.reload calls, and review the refactor tracked in #1006 alongside the ActiveRecord::Base assumption. Determine which model interface is intended to be supported; done means the behavior is clarified and the refactor has an explicit, verified contract.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- api, backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100