1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-23 15:19:38 +02:00
Maybe/app/models/address.rb
Luan Estradioto 6a21f26d2d
Some checks failed
Publish Docker image / ci (push) Has been cancelled
Publish Docker image / Build docker image (push) Has been cancelled
Fix: No comma when locality is empty (small fix) (#2111)
* Fix: No comma when locality is empty

* better cleanup on address string

* fix test to one-liner

* add more testing
2025-04-16 20:26:45 -05:00

18 lines
434 B
Ruby

class Address < ApplicationRecord
belongs_to :addressable, polymorphic: true
def to_s
string = I18n.t("address.format",
line1: line1,
line2: line2,
county: county,
locality: locality,
region: region,
country: country,
postal_code: postal_code
)
# Clean up the string to maintain I18n comma formatting
string.split(",").map(&:strip).reject(&:empty?).join(", ")
end
end