This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 引入文件 | |
# require 'mongoid/counter_cache' | |
## 插入Document行後 | |
# include Mongoid::Relations::CounterCache | |
## 默認 | |
# referenced_in :person, :inverse_of => :posts, :counter_cache => true | |
## 自定義 | |
# referenced_in :person, :inverse_of => :posts, :counter_cache => :posts_count | |
module Mongoid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 引入文件 | |
# require 'mongoid/activity' | |
## 插入Document行後 | |
# include Mongoid::Activity::Trackable | |
# 啟用跟蹤 | |
# tracking :person => :follower, :scope => :followable, :create_bones => 5, :destroy_bones => -3 | |
module Mongoid | |
module Activity | |
module Trackable | |
extend ActiveSupport::Concern |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
ActiveAdmin::Views::Pages::Base.class_eval do | |
private | |
# Renders the content for the footer | |
def build_footer | |
div :id => "footer" do | |
para "Copyright © #{Date.today.year.to_s} #{link_to('Example.com', 'http://example.com')}. Powered by #{link_to('Active Admin', 'http://www.activeadmin.info')} #{ActiveAdmin::VERSION}".html_safe | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /lib/active_admin_dsl.rb | |
require 'active_admin/dsl.rb' | |
include CollectiveIdea::Acts::NestedSet::Helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<sign signid='0'> | |
<style type='text/css'> | |
#signature{font-size:13px;font-family:'STHeiti Light';color:#9fa0a0} | |
#signature .b{font-size:21px;font-weight:700;margin-right:60px} | |
#signature .s{font-size:11px;font-style:italic} | |
#signature dl,#signature a{line-height:2;color:#9fa0a0} | |
#signature dl dt{width:60px;float:left;text-align:right;margin:0 .5em} | |
#signature dl dt:after{content:" : "} | |
#signature .logo{padding-right:13px;background:#fff;border-bottom-right-radius:18px;margin-bottom:-27px} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>库存更新结果</title> | |
<link href="../css/base.css" type="text/css" rel="stylesheet"> | |
<style type="text/css"> | |
body { | |
background: url('../images/allbg.gif'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**** 隐藏对象 ****/ | |
function hide(el){ | |
el.style.display='none'; | |
} | |
/**** 找对象 ****/ | |
function find(id){ | |
return document.getElementById(id); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
weekly = 4.weeks.ago.beginning_of_day..4.weeks.ago.end_of_day # 时间段 | |
conditions = Order.where(created_at:weekly).selector # 查询条件 | |
reduce = <<javascript | |
function(doc, prev) { | |
if(doc.paid_at == '') { | |
prev.quantity += doc.quantity; | |
prev.payment += doc.payment; | |
} | |
if(prev.skus[doc.sku_id] == undefined) { | |
prev.skus[doc.sku_id] = {quantity: 0, payment:0}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show_props(str) | |
props = str.split(';') # 切割 | |
if props.is_a?(Array) | |
str = "<dl class='props'>" | |
props.each do |property| | |
prop_arr = property.split(':') # 切割 | |
if prop_arr.is_a?(Array) && prop_arr.count == 4 | |
str += "<dt title='#{prop_arr[0]}'>#{prop_arr[2]}</dt><dd title='#{prop_arr[1]}'>#{prop_arr[3]}</dd>" | |
else | |
str += "<dt class='warning'>提示:</dt><dd>无属性</dd>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
user = User.all[0] | |
user_id = user.nick.to_s | |
start_at = "2012-03-01".to_date | |
end_at = "2012-03-31".to_date | |
range = (start_at.beginning_of_day..end_at.end_of_day) | |
trades = Trade.where(seller_nick: user_id, pay_time: range, is_brand_sale: true) | |
CSV.open("./#{Time.now.to_i}.csv", "wb:GB18030") do |csv| | |
csv << ['订单号', '宝贝ID', '款式', '商家SKU', '数量','应付', '折扣', '实付', '付款时间', '发货时间', '退款ID'] | |
trades.each do |trade| |
OlderNewer