Total Complexity | 2 |
Total Lines | 16 |
Duplicated Lines | 0 % |
Changes | 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 |