@phases.each do |phase|
phase['topics'].each do |topic|
topic['videos'].each do |video|
if video["id"] == params['id'].to_i
@phase = phase
@video = video
end
end
end
end
@phases.each do |phase|
phase['topics'].each do |topic|
topic['videos'].each do |video|
if video["id"] == params['id'].to_i + 1
@next_video = video
end
end
end
end
@phases.each do |phase|
phase['topics'].each do |topic|
topic['videos'].each do |video|
if video["id"] == params['id'].to_i - 1
@previous_video = video
end
end
end
end
The following code seems trivial to refactor: