Sha256: 8d1891832c33127eca23eeb6c302ddaf5b3d7bad7033d8463991d9d7132b907b

Contents?: true

Size: 653 Bytes

Versions: 1

Compression:

Stored size: 653 Bytes

Contents

class Property < MLS::Model

  include MLS::Slugger
  include MLS::Avatar

  belongs_to :contact, :class_name => 'Account'

  has_many :listings
  has_many :localities
  has_many :regions, :through => :localities
  has_many :photos, -> { order('photos.order ASC') }, :as => :subject, :inverse_of => :subject
  # has_many :regions

  has_many   :addresses
  has_one    :address, -> { where(:primary => true) }

  def default_contact
    @default_contact ||= listings.where(lease_state: :listed, ghost: false, authorized: true)
            .where({ type: ['Lease', 'Sublease']})
            .order(size: :desc)
            .first.try(:contact)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mls-1.3.0 lib/mls/property.rb