02 2014 档案
摘要:还有半个小时下班,写点今天做的功能,打发打发时间. 两个类,订单类和序列号类. 订单类 1 class GroupOrder 2 include Mongoid::Document 3 include Mongoid::Timestamps 4 5 field :order_code, type: String 6 field :cellphone_num, type: String 7 field :quantity, type: Integer 8 field :state, type: String 9 10 has_many :verify_s...
阅读全文
摘要:Module是Class的父类:>> Class.superclass=> Modulemodule 没有实例变量module 没有new不能生成实例对象module内可以有常量>> module Test>> PI=3.14>> end=> 3.14>> Test.PI>> Test::PI=> 3.14module的方法有两种,一种是module方法,这类方法可以直接调用。>> module Test>> def Test.test_method>> puts &q
阅读全文
摘要:转自http://huacnlee.com/blog/use-etag-in-your-rails-app-to-speed-up-loading/什么是 ETag网上关于 ETag 的解释有很多,我这里简单的说明一下我的理解:ETag 是 HTTP 协议的标准参数,一般是这样的:”686897696a7c876b7e” 一段字符,它能通过一段字符来判断浏览器 cache 的内容是否和服务端返回的内容是否相同,从而来决定是否要重新从服务器下载东西 (HTTP 状态 200 - 重新下载 / 304 - 没有更新)。ETag 使用场景举例这个东西非常适合用于动态内容上面,以减少不必要的 HTML
阅读全文