I have same problem and dont understand how to realise it's idea. Here's my code:
controller.rb
def update
begin
dot_applications = DotApplication.where(id: params[:ids])
bad_dot_app_update = []
dot_applications.each do |dot_application|
if dot_application.update!(lead_source_id: resource_params[:lead_source_id])
dot_application.update!(lead_source_id: resource_params[:lead_source_id])
else
bad_dot_app_update << dot_application.update!(lead_source_id: resource_params[:lead_source_id])
end
end
render dialog: {
close_dialog: true,
success_message: "The lead source was changed for selected applicants."
}
rescue StandardError => error
render dialog: {
close_dialog: true,
error_message: "Can't update lead sources because #{error.message}"
}
end
end
I want to collect not updated 'dot_aplication' add it to array and insert it to rescue StandartError. Help me please.