Добавьте следующие ассоциации в ваших моделях,
user.rb
class User < ActiveRecord::Base
belongs_to :born_country, foreign_key: :born_country_id, class_name: 'Country'
belongs_to :live_at_country, foreign_key: :live_at_country_id, class_name: 'Country'
delegate :name, to: :born_country, prefix: true
delegate :name, to: :lived_at_country, prefix: true
end
country.rb
class Country < ActiveRecord::Base
has_many :born_users, foreign_key: :born_country_id, class_name: 'User'
has_many :live_at_users, foreign_key: :live_at_country_id, class_name: 'User'
end
Вы можете проверить это ниже,
@users = User.includes(:born_country, :lived_at_country).each do |user|
puts user.born_at_country_name
puts user.lived_at_country_name
end