Skip to content

Instantly share code, notes, and snippets.

@travisdmathis
Last active August 29, 2015 14:12
Show Gist options
  • Save travisdmathis/4e573f0e0c920867f099 to your computer and use it in GitHub Desktop.
Save travisdmathis/4e573f0e0c920867f099 to your computer and use it in GitHub Desktop.
refactor
def is_catalog_unique?(catalogs, user, folder_name)
if catalogs.blank?
@catalog = user.root_catalog
children = @catalog.live_children
children.each do |child|
if folder_name.gsub("+", " ") == child.name
return false
end
end
else
catalogs.each do |catalog_id|
@catalog = user.role.catalogs.find_by_id(catalog_id)
children = @catalog.live_children
children.each do |child|
if folder_name.gsub("+", " ") == child.name
return false
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment