diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb
index 17c6d56c8b9776fec18150f3966a531703d7fedd..4c63bec90e57b2e1e9a60d3898cabbc33f181c3b 100644
--- a/app/controllers/projects/artifacts_controller.rb
+++ b/app/controllers/projects/artifacts_controller.rb
@@ -37,8 +37,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
   end
 
   def latest_succeeded
-    path = ref_name_and_path.last
-    target_path = artifacts_action_path(path, project, build)
+    target_path = artifacts_action_path(@path, project, build)
 
     if target_path
       redirect_to(target_path)
@@ -63,17 +62,13 @@ class Projects::ArtifactsController < Projects::ApplicationController
 
   def build_from_ref
     if params[:ref_name_and_path]
-      ref_name = ref_name_and_path.first
+      ref_name, @path = extract_ref(params[:ref_name_and_path])
       builds = project.latest_successful_builds_for(ref_name)
 
       builds.find_by(name: params[:job])
     end
   end
 
-  def ref_name_and_path
-    @ref_name_and_path ||= extract_ref(params[:ref_name_and_path])
-  end
-
   def artifacts_file
     @artifacts_file ||= build.artifacts_file
   end