Rails で If-Modified-Since の解釈をしたい

Rails で If-Modified-Since を解釈して Last-Modified を出したい場合、一々自身で解釈しなくても fresh_when メソッドや stale? メソッドが用意されているので、これを利用することで簡単に対応することができます。

ビューのレンダリング負荷や転送量の軽減が見込めるため、それなりに効果があります。

実際に利用する場合は、例えば @category.itemsupdated_at を見て Last-Modified を出したい場合、事前に取りだす項目群を order('updated_at DESC') で取りだしておいて先頭項目を参照するなど、多少の工夫が必要となる場合があります。

Ruby 2.1.x で LoadError: cannot load such file -- bcrypt_ext が出る

気付いたら RubyInstaller に 2.1.4 が出ていたので、さっそく入れて試してみたところ……。

LoadError: cannot load such file -- bcrypt_ext
LoadError: cannot load such file -- 2.1/bcrypt_ext

とか出てくれまして。色々探してみたところ、以下のような感じで対処可能でした。

C:\> gem install --no-ri --no-rdoc bcrypt
C:\> cd (path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri
C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> ruby extconf.rb
C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> make
C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> make install

何なのこの残念感。