Completed
Push — master ( ee3653...30ef8d )
by
unknown
02:04 queued 32s
created

Category.i18n_key()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
class Category < ActiveRecord::Base
2
  has_many :categorizations
3
  has_many :sessions, :through => :categorizations
4
5
  def self.find_or_create_defaults
6
    cnf = YAML.load_file(File.join(Rails.root, 'config', 'categories.yml'))
7
    cnf.each do |key, val|
8
      Category.where(id: key).first_or_initialize.update(name: val)
9
    end
10
  end
11
12
  def i18n_key
13
    name.gsub(/&/, '').gsub(/\s+/, '_').downcase
14
  end
15
16
end
17