-
Notifications
You must be signed in to change notification settings - Fork 41
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
do not destroy location relations with invalid location updates #1893
Conversation
end | ||
|
||
it 'should create externally linked media resources' do | ||
update_params[:subjects].merge!(locations: external_locs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use update_params[:subjects][:locations] = external_locs
instead of update_params[:subjects].merge!(locations: external_locs)
.
9032b6d
to
4ecb8a6
Compare
if locations_update | ||
new_locations = add_locations(locations, resource) | ||
end | ||
resource.save! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually - think i'll move this to a block for the locations update method.
4ecb8a6
to
cde8f3a
Compare
subject.locations.build(location_params) | ||
new_locations = if locations.blank? | ||
nil | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align else
with if
.
4d1a22c
to
0f6a8bd
Compare
subject.locations = add_locations(locations, subject) | ||
subject.save! | ||
super(update_params, id) | ||
add_locations(locations, resource) do |subject| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass &:save!
as an argument to add_locations
instead of a block.
run the has_many update after the resource validation has occurred not before
0f6a8bd
to
53cf8a9
Compare
thank you hound for barking at me for a simpler solution...much better now. |
closes #1885 - avoid invalid location updates on the media resource. Make sure these validations pass before updating the relation to reflect the updated location resource.
Describe your change here.
Review checklist
apiary.apib
file?