Function: projectile--rails-view-key

projectile--rails-view-key is a byte-compiled function defined in projectile.el.

Signature

(projectile--rails-view-key REL-PATH)

Documentation

Return the namespaced singular Rails resource key of the view file REL-PATH.

Rails views live in a per-resource directory (e.g. "app/views/users/"), so the key is that directory's path with its final segment singularized;
"app/views/admin/users/index.html.erb" keys as "admin/user".

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--rails-view-key (rel-path)
  "Return the namespaced singular Rails resource key of the view file REL-PATH.
Rails views live in a per-resource directory (e.g. \"app/views/users/\"),
so the key is that directory's path with its final segment singularized;
\"app/views/admin/users/index.html.erb\" keys as \"admin/user\"."
  (when (string-prefix-p "app/views/" rel-path)
    (let ((rest (substring rel-path (length "app/views/"))))
      (when-let* (((string-match-p "/" rest))
                  (resource-dir (directory-file-name (file-name-directory rest))))
        (concat (or (file-name-directory resource-dir) "")
                (projectile--singularize
                 (file-name-nondirectory resource-dir)))))))