http://api.rubyonrails.org/classes/ActiveSupport/Concern.htmlによると、懸念を継承するように見えます。だから、私はAddressable
からSimpleAddressable
を引き抜きました。
module SimpleAddressable
extend ActiveSupport::Concern
included do
validates :address, length: { maximum: 200 }, allow_nil: true
validates :city, length: { maximum: 50 }, allow_nil: true
validates :region, length: { maximum: 50 }, allow_nil: true
validates :postal_code, length: { maximum: 20 }, allow_nil: true
end
end
module Addressable
extend ActiveSupport::Concern
include SimpleAddressable
included do
validates :mailing_address, length: { maximum: 200 }, allow_nil: true
validates :mailing_city, length: { maximum: 50 }, allow_nil: true
validates :mailing_region, length: { maximum: 50 }, allow_nil: true
validates :mailing_postal_code, length: { maximum: 20 }, allow_nil: true
belongs_to :country, optional: true
end
end