mirror of
https://github.com/we-promise/sure.git
synced 2026-04-08 06:44:52 +00:00
* Add backend for property account details * Rubocop updates * Add property form with details * Revert "Rubocop updates" This reverts commit 05b0b8f3a4eb8f444997b9bef18ffc972a8be69e. * Bump brakeman to latest version * Add overview section to property view * Lint fixes
25 lines
507 B
Ruby
25 lines
507 B
Ruby
class Address < ApplicationRecord
|
|
belongs_to :addressable, polymorphic: true
|
|
|
|
validates :line1, :locality, presence: true
|
|
validates :postal_code, presence: true, if: :postal_code_required?
|
|
|
|
def to_s
|
|
I18n.t("address.format",
|
|
line1: line1,
|
|
line2: line2,
|
|
county: county,
|
|
locality: locality,
|
|
region: region,
|
|
country: country,
|
|
postal_code: postal_code
|
|
)
|
|
end
|
|
|
|
private
|
|
|
|
def postal_code_required?
|
|
country.in?(%w[US CA GB])
|
|
end
|
|
end
|