1 # == Schema Information
3 # Table name: languages
5 # code :string not null, primary key
6 # english_name :string not null
10 class Language < ActiveRecord::Base
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|
19 Language.update(k, :english_name => v["english"], :native_name => v["native"])
20 rescue ActiveRecord::RecordNotFound
21 Language.create do |l|
23 l.english_name = v["english"]
24 l.native_name = v["native"]
33 name += " (#{native_name})" unless native_name.nil?