1 # == Schema Information
3 # Table name: languages
5 # code :string not null, primary key
6 # english_name :string not null
10 class Language < ApplicationRecord
11 self.primary_key = "code"
13 has_many :diary_entries, :foreign_key => "language"
16 Language.transaction do
17 YAML.safe_load(File.read(file)).each do |k, v|
18 Language.update(k, :english_name => v["english"], :native_name => v["native"])
19 rescue ActiveRecord::RecordNotFound
20 Language.create do |l|
22 l.english_name = v["english"]
23 l.native_name = v["native"]
31 name += " (#{native_name})" unless native_name.nil?