Extract ProcedurePath#find_by_path
This commit is contained in:
parent
9a216ae705
commit
de908ef4be
2 changed files with 8 additions and 4 deletions
|
@ -205,10 +205,7 @@ class Admin::ProceduresController < AdminController
|
||||||
|
|
||||||
def path_list
|
def path_list
|
||||||
json_path_list = ProcedurePath
|
json_path_list = ProcedurePath
|
||||||
.joins(:procedure)
|
.find_with_path(params[:request])
|
||||||
.where(procedures: { archived_at: nil })
|
|
||||||
.where("path LIKE ?", "%#{params[:request]}%")
|
|
||||||
.order(:id)
|
|
||||||
.pluck(:path, :administrateur_id)
|
.pluck(:path, :administrateur_id)
|
||||||
.map do |path, administrateur_id|
|
.map do |path, administrateur_id|
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,13 @@ class ProcedurePath < ApplicationRecord
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
belongs_to :administrateur
|
belongs_to :administrateur
|
||||||
|
|
||||||
|
def self.find_with_path(path)
|
||||||
|
joins(:procedure)
|
||||||
|
.where.not(procedures: { aasm_state: :archivee })
|
||||||
|
.where("path LIKE ?", "%#{path}%")
|
||||||
|
.order(:id)
|
||||||
|
end
|
||||||
|
|
||||||
def hide!
|
def hide!
|
||||||
destroy!
|
destroy!
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue