diff --git a/Gemfile b/Gemfile index f44b49b85..c901c0e56 100644 --- a/Gemfile +++ b/Gemfile @@ -52,7 +52,7 @@ gem 'daemons', '~> 1.1.9' # process delayed jobs gem 'newrelic_rpm', '~> 3.9.9.275' # country listing -# gem 'countries', '~> 0.10.0' +gem 'countries', '~> 0.10.0' group :development do # dev tools diff --git a/Gemfile.lock b/Gemfile.lock index 0108658db..9097efcef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -106,6 +106,9 @@ GEM coffee-script-source execjs coffee-script-source (1.8.0) + countries (0.10.0) + currencies (~> 0.4.2) + currencies (0.4.2) daemons (1.1.9) database_cleaner (1.3.0) debug_inspector (0.0.2) @@ -439,6 +442,7 @@ DEPENDENCIES cancancan (~> 1.9.2) capybara (~> 2.4.1) coffee-rails (~> 4.1.0) + countries (~> 0.10.0) daemons (~> 1.1.9) database_cleaner (~> 1.3.0) delayed_job_active_record (~> 4.0.3) diff --git a/app/models/address.rb b/app/models/address.rb index acc147985..32f29d6fd 100644 --- a/app/models/address.rb +++ b/app/models/address.rb @@ -8,10 +8,13 @@ class Address < ActiveRecord::Base ] belongs_to :contact - belongs_to :country_deprecated, foreign_key: "country_id" has_paper_trail class_name: 'AddressVersion' + def country + Country.new(country_code) + end + class << self # def validate_postal_info_types(parsed_frame) # errors, used = [], [] diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 53db6d3cc..946977555 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -1,5 +1,4 @@ class Registrar < ActiveRecord::Base - belongs_to :country_deprecated, foreign_key: "country_id" has_many :domains, dependent: :restrict_with_error has_many :contacts, dependent: :restrict_with_error has_many :api_users, dependent: :restrict_with_error @@ -23,6 +22,10 @@ class Registrar < ActiveRecord::Base name end + def country + Country.new(country_code) + end + class << self def search_by_query(query) res = search(name_or_reg_no_cont: query).result diff --git a/app/models/user.rb b/app/models/user.rb index aed260b28..10e37cd9e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -6,8 +6,6 @@ class User < ActiveRecord::Base # After activisation, system should require to change temp password. # TODO: Estonian id validation - belongs_to :country_deprecated, foreign_key: "country_id" - validates :username, :password, presence: true validates :identity_code, uniqueness: true, allow_blank: true validates :identity_code, presence: true, if: -> { country.iso == 'EE' } @@ -21,6 +19,10 @@ class User < ActiveRecord::Base username end + def country + Country.new(country_code) + end + private def validate_identity_code