Worlds Bets
This commit is contained in:
24
app/models/world_country.rb
Normal file
24
app/models/world_country.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
# == 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
|
||||
Reference in New Issue
Block a user