Sha256: a52e0d7ac6fc010a94b8dc0d2a11509fd7949bc38740bab79152f77d233b60c5

Contents?: true

Size: 962 Bytes

Versions: 2

Compression:

Stored size: 962 Bytes

Contents

class Supplier < ActiveRecord::Base
  validates :title, :presence => true
#  scope :current_city, lambda {|id| where("city_id", id)}
  acts_as_gmappable :check_process => false
  acts_as_url :title, :url_attribute => :slug, :scope => :state_id

  def gmaps4rails_address
    country = State.find_by_id(self.state_id).country.name
    "#{self.address1}, #{self.town}, #{self.state.name}, #{self.zip_code}"
  end

  def gmaps4rails_title 
    self.name
  end

  def gmaps4rails_infowindow
    "<a href='/#{self.state.abbr}/#{self.slug}'>#{self.title}</a>"
  end

  belongs_to :state
  has_one :user
  has_many :products
  has_many :messages
  has_many :hours
  has_many :pickups
  has_many :pickup_locations
  has_many :images, :as => :viewable, :order => :position, :dependent => :destroy
  accepts_nested_attributes_for :hours
  has_many :supplier_invoices
  has_and_belongs_to_many :taxons
  has_and_belongs_to_many :shipping_methods
  has_many :deliveries
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_suppliers-0.0.1 app/models/supplier.rb
spree_suppliers-0.60.3 app/models/supplier.rb