@chunlea HackShanghai 玩智能硬件吗?
#3 楼 @akirapanda 同求
# -*- encoding: utf-8 -*-
module ActiveRecord
module CustomerCache
extend ActiveSupport::Concern
included do |base|
belongs_to_document :customer # 客人
before_validation :set_customer_cache, if: :customer_cache? # 解决 belongs_to :customer 时 customer= 继承问题。
end
# 缓存客人信息
def customer=(val)
self.customer_id = val.try(:id).try(:to_s) # 关联客人
self.customer_username = val.try(:username) # 帐号
self.customer_nickname = val.try(:nickname) # 昵称
self.customer_name = val.try(:name) # 收货人
self.customer_mobile = val.try(:mobile) # 手机号
self.customer_address = val.try(:address) # 收货地址
end
alias :set_customer_cache= :customer=
private
def set_customer_cache
self.set_customer_cache = self.customer
end
def customer_cache?
self.customer_id_changed? && self.respond_to?(:customer)
end
end
end
多处调用:
# -*- encoding: utf-8 -*-
class Order < ActiveRecord::Base
include ::ActiveRecord::CustomerCache
include ::ActiveRecord::StoreCache
include ::ActiveRecord::Tracker
extend Enumerize
has_many :line_items
serialize :carts, JSON
after_initialize :set_default_carts
has_many_documents :issues
attr_accessible :order_no, :quantity, :price, :shipping_fee, :payment, :status, :created_on, :paid_on, :shipped_on, :signed_on, :current_user, :assigned_count, :assigned_at
enumerize :status, in: { exception: -1, pending: 0, paid: 2, shipping: 3, shipped: 4, signed: 6, billed: 9, refund: 11, closed: 13, archived: 99 }, default: :pending, scope: true, predicates: { prefix: true }
paginates_per 10
default_scope -> { order('updated_at DESC, customer_id DESC') }
# .............
申请试用:
联系方式 : [email protected] 需要管理的日志类型:Sidekiq,Rails 操作系统:Linux
家乡的公司 :plus1:
p SecureRandom.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
:plus1:
招聘文案很陕西化,看起来和 http://www.shou65.com/help/jobs 有的一拼~
深圳大疆,在四轴飞行器领域很牛~ :plus1:
#4 楼 @ChrisLoong http://www.chihuohezi.com 我们小伙伴做的,给点意见~
自建店铺这个事,太小店铺没流量,太大需要对接供应链的都自己做系统,或是靠在巨人肩膀上,做全平台~
有没有全平台对接呀~铺货到京东、天猫、一号店、亚马逊之类的?!
好姑娘,上个头像先~
OmniGraffle 随手画画~
:plus1:
建议不要使用 hr 邮箱,我们【收留我】的招聘邮箱是:hello[at]shou65.com 是不是更人性
uE9hcFBvBxo6
4AH69jN2oK44
P8U46793V4jU
mifqLLa5Z8TQ
已用,谢谢
社保,关系到你的个人积分,等你们有了孩子,排队上幼儿园时就知道有什么用了~
告诉你们一个秘密,腾讯的 OPENID 不可作为 UID 使用,因为每个 API_KEY 所获取的 OPENID 都不一样,
#2 楼 @42thcoder 写在 model 里,因为不止在前台要用,其他后台场景中需要用~
def email_safe
return nil if self.email.nil?
self.email.sub /(.*)@(.*)/ do
$1[0..($1.size/2-1)].ljust($1.size, '*') + '@' + $2
end
end
def mobile_safe
return nil if self.mobile.nil?
self.mobile.sub /(\d{3})(\d{4})(\d*)/ do
$1+'****'+$3
end
end
mount_uploader :image, PhotoUploader