Sha256: e13b32548cb3451016bd145d198823f07832710eefd90815b6b7cb45644886ea
Contents?: true
Size: 1.13 KB
Versions: 87
Compression:
Stored size: 1.13 KB
Contents
module Pageflow module FoldersHelper def collection_for_folders(current_account, current_folder = nil) accounts = AccountPolicy::Scope.new(current_user, Pageflow::Account) .entry_creatable.includes(:folders).where('pageflow_folders.id IS NOT NULL') .order(:name, 'pageflow_folders.name') option_groups_from_collection_for_select(accounts, :folders, :name, :id, :name, selected: current_folder.try(:id), disabled: disabled_ids(accounts, current_account)) end private def disabled_ids(accounts, current_account) folders_array = accounts.map(&:folders).to_a folders_array.delete_if do |account_folders| account_folders[0][:account_id] == current_account.id end folders_array.map(&:to_a).map do |account_folders| account_folders.map(&:id) end.flatten end end end
Version data entries
87 entries across 87 versions & 1 rubygems