Class: Pressroom::Tag
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Pressroom::Tag
- Includes:
- Sluggable
- Defined in:
- app/models/pressroom/tag.rb
Constant Summary
Constants included from Sluggable
Class Method Summary collapse
-
.for_names(names) ⇒ Object
Finds or creates one tag per distinct non-blank name.
Class Method Details
.for_names(names) ⇒ Object
Finds or creates one tag per distinct non-blank name.
16 17 18 19 20 21 22 |
# File 'app/models/pressroom/tag.rb', line 16 def self.for_names(names) Array(names) .map { |name| name.to_s.strip } .reject(&:empty?) .uniq .map { |name| find_or_create_by!(slug: slugify(name)) { |tag| tag.name = name } } end |