33 lines
720 B
Ruby
33 lines
720 B
Ruby
class City < ApplicationRecord
|
|
belongs_to :province, required: true
|
|
has_one :profile
|
|
|
|
validates :name, presence: true,
|
|
length: 1..255,
|
|
format: {
|
|
with: /\A[[:word:]\s\-']+\z/,
|
|
message: 'only allows letters, digits "-", "\'", and space'
|
|
}
|
|
|
|
end
|
|
|
|
# == Schema Information
|
|
# Schema version: 20210425062048
|
|
#
|
|
# Table name: cities
|
|
#
|
|
# id :bigint not null, primary key
|
|
# name :string(255)
|
|
# province_id :bigint
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_cities_on_province_id (province_id)
|
|
#
|
|
# Foreign Keys
|
|
#
|
|
# fk_rails_ea36d40e0b (province_id => provinces.id)
|
|
#
|