25 lines
658 B
Ruby
25 lines
658 B
Ruby
# == Schema Information
|
|
#
|
|
# Table name: world_countries
|
|
#
|
|
# id :integer not null, primary key
|
|
# code :string not null
|
|
# name :string not null
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
#
|
|
class WorldCountry < ApplicationRecord
|
|
has_many :world_participants
|
|
|
|
validates :code, presence: true, uniqueness: true
|
|
validates :name, presence: true, uniqueness: true
|
|
|
|
def self.add_countries(str)
|
|
str.split(";", -1).each do |c|
|
|
name = c.split(",", -1).first
|
|
code = c.split(",", -1).last
|
|
WorldCountry.create(name: name, code: code)
|
|
end
|
|
end
|
|
end
|