Class: Tag

Inherits:
ApplicationRecord show all
Defined in:
app/models/tag.rb

Overview

Tag Class Includes all tags in the system (lowercase)

Tag

id: integer,
name: string,
created_at: datetime,
updated_at: datetime

Instance Method Summary collapse

Instance Method Details

#find_similarformated String?

Returns similar tags if found or nil


23
24
25
26
27
28
29
30
# File 'app/models/tag.rb', line 23

def find_similar
  seed_data.each do |tag, candidates|
    candidates.each do |candidate|
      return "Maybe the tag #{name} is wrong. Did you mean #{tag}?" if name.match(/#{candidate}/) && name != tag
    end
  end
  nil
end