class ElFinder2::Command::Parents
Returns all parent folders and its subfolders on required (in connector options) deep. This command is invoked when a directory is reloaded in the client. Data provided by ‘parents’ command should enable the correct drawing of tree hierarchy directories.
Public Instance Methods
execute()
click to toggle source
# File lib/el_finder2/command/parents.rb, line 8 def execute folders = ElFinder2::Folder.where( 'id IN (:ancestor_ids) OR parent_id IN (:ancestor_ids)', ancestor_ids: @file.ancestor_ids ) render json: { tree: ActiveModel::ArraySerializer.new(folders).as_json } end
Private Instance Methods
parse_params!(params)
click to toggle source
# File lib/el_finder2/command/parents.rb, line 19 def parse_params!(params) target = params[:target] fail ElFinder2::Error.new(%w(errCmdParams parents)) unless target path = to_path(target) @file = ElFinder2::File.find_by_path(path) fail ElFinder2::Error.new('errFolderNotFound') unless @file end