1 class Language < ActiveRecord::Base
2 self.primary_key = "code"
4 has_many :diary_entries, :foreign_key => 'language'
7 Language.transaction do
8 YAML.load(File.read(file)).each do |k, v|
10 Language.update(k, :english_name => v["english"], :native_name => v["native"])
11 rescue ActiveRecord::RecordNotFound
12 Language.create do |l|
14 l.english_name = v["english"]
15 l.native_name = v["native"]
24 name += " (#{native_name})" unless native_name.nil?