# encoding:utf-8
class Address < ActiveRecord::Base
  has_paper_trail
  self.table_name = "addresses"
  belongs_to :user, :foreign_key => :user_id
  belongs_to :wx_user, :foreign_key => :wx_user_id

  def address_format
    return self.province + self.city + self.district + self.address
  end

  rails_admin do
    navigation_label '用户信息管理'
    weight -55
    
    list do   
      filters [:user,:tel,:province,:city]
      field :id
      # field :user_id
      field :user
      field :wx_user
      field :contact
      field :tel
      field :province
      field :city
      field :district
      field :address
      field :address_format
      field :postcode
      field :state
      field :remark
      # field :created_at
      field :updated_at
    end
    show do   
      field :id
      field :user_id
      field :user
      field :wx_user_id
      field :wx_user
      field :tel
      field :contact
      field :address
      field :province
      field :city
      field :district
      field :postcode
      field :state
      field :remark
      field :created_at
      field :updated_at
    end

    edit do
      field :user_id
      field :wx_user_id
      field :tel
      field :contact
      field :address
      field :province
      field :city
      field :district
      field :postcode
      field :state
      field :remark
    end
  end
end
