原创 A Better Way to Manage the Rails Secret Token

A Better Way to Manage the Rails Secret TokenMay 20th, 2013tl;dr Don’t hardcode secret tokens. Load them from the enviro

原创 Sublime 中文輸入

Sublime 中文輸入cd ~/.config/sublime-text-2/Packagesgit clone https://github.com/xgenvn/InputHelper.git+ 安裝後重啓 Sublime+ 默認的快

原创 kind_of? vs. instance_of? vs. is_a?

kind_of?  和 is_a? 是同義詞,用於判斷某個對象是某個類或者子類的實例instance_of? 僅判斷某個對象是否是某個類的實例

原创 Resque vs DelayedJob

Resque 支持多隊列DelayedJob支持細粒度的優先級DelayedJob workers 簡單易於修改Resque 依賴於redis,本身提供了監控功能DelayedJob 依賴於數據庫

原创 helper_method和helper的區別

helper_method:  將controller中定義的共享給view和helper使用,在helper中定義一個同名的方法,該方法最終調用controller中方法helper則是將整個文件mixin如view

原创 rails session 的加密與解密

rails 採用 HMAC-SHA1 進行加密,加密過程由ActiveSupport::MessageVerifier類實現:secret ='b6ff5a9c3c97bf89afe9a72e6667bafe855390e8570d46e1

原创 nil? blank? empty? 的區別

nil?作用於任何對象,當對象是nil是返回trueempty?作用於String Hash Array,當他們長度爲0時返回true," ".empty? 返回falseblank?作用於任何對象,當對象是nil false empty

原创 building a secure REST API within Ruby on Rails

There are several schemes for authenticating API requests, and they're different than normal authentication provided by 

原创 我的友情鏈接

51CTO博客開發

原创 關閉 asset pipeline (sprockets)日誌消息

新建 config/initializers/quiet_assets.rbif Rails.env.development?  Rails.application.assets.logger = Logger.new(File.join(

原创 model中調用routes

Rails.application.routes.url_helpers