前言
目前业务越来越多,很多业务可能需要拆分成不同的应用,不同的应用之间如何互享用户信息,这时就需要用到单点登录(Single Sign On),简称为 SSO。
这里主要针对doorkeeper作讲解
目前业务越来越多,很多业务可能需要拆分成不同的应用,不同的应用之间如何互享用户信息,这时就需要用到单点登录(Single Sign On),简称为 SSO。
这里主要针对doorkeeper作讲解
在项目中经常会存储一些短时候内比较重要的数据,或者一些临时数据,这种数据以前一般我都把它 存到redis中,后来想想如果不是很重要的临时数据就没必要往redis里放了,直接用cache可能更方便
它是一个抽象类,有很多cache store的实现 rails中的这个类提供了和缓存交互的很多基本的方法,包括(read,write,delete,exist?,fetch),下面说下具体实现
先说一下FileStore,这种存储方式Rails默认的存储方式,他是将数据存储到系统文件,默认将文件存储到项目的/tmp/cache下面,你可以修改它的存储路径
1
|
|
上面说FileStore是Rails默认的存储方式,看下面这句代码就知道了
1
|
|
本文翻译,改编自Include vs Extend in Ruby
在类中引用一个模块,有两种方式,一种是include,另一种是extend,两种的大致区别就是:
include是给class增加一个实例方法,而extend是增加一个类方法
我们看一下小例子.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
有时候在一张表里面有两个字段,但是实际表单里其实只有一个文本框输入,比如老外的名字分first_name last_name, 在表里面是分开保存的,但其实是在一个文本框中输入的,这里使用virtal attriubtes最恰当不过了,看表结构
1 2 3 4 5 6 7 8 9 10 11 |
|
在类中可以将一个实例方法重新命名,注意的是新方法在前面,用空格格开
和alias一样,只是他是module的一个私有方法,而且它的方法名可以是字符中,而alias不行,看代码
hello everybody, this is my first post, I'am very happy, bescuse it is successful.
如果想了解微信相关开发的东西请到我的新浪博客