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 has_many :diary_entries, :foreign_key => "language", :inverse_of => :language
14 Language.transaction do
15 YAML.safe_load_file(file).each do |k, v|
16 Language.update(k, :english_name => v["english"], :native_name => v["native"])
17 rescue ActiveRecord::RecordNotFound
18 Language.create do |l|
20 l.english_name = v["english"]
21 l.native_name = v["native"]
29 name += " (#{native_name})" unless native_name.nil?