Sha256: 44ce514fac09daf8852443d5c355d125df360de570f2fb834496155008a27cca
Contents?: true
Size: 629 Bytes
Versions: 1
Compression:
Stored size: 629 Bytes
Contents
module Addresses class Address < ActiveRecord::Base attr_accessor :state_id belongs_to :city belongs_to :neighborhood belongs_to :addressable, polymorphic: true validates :zipcode, :number, :city_id, :state_id, presence: true after_find :after_find def to_s "#{self.street}, #{self.number}, #{self.neighborhood}. #{self.city.name} - #{self.city.state.abbreviation}" end private # => Used to fill state_id def after_find self.state_id = self.city.state.id unless self.city.nil? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
addresses-0.0.4 | app/models/addresses/address.rb |