(mshk) clips & crops

Twitter: @mshk
My Google Profile

December 30, 2011 at 4:27pm
Home

wii_paginateでTwitter Bootstrapに対応したページャーを出力する

Twitter Bootstrapが提供するpager(元ネタはRdioらしい)を、Ruby Gemのwii_paginateで使おうと思ったら色々はまったので、メモです。

Twitter Bootstrap

http://twitter.github.com/bootstrap/#navigation

wii_paginateは、RailsのActiveRecordと組み合わせて使えるページャーヘルパーです。

https://github.com/mislav/will_paginate/wiki

Twitter Bootstrap + will_paginateの組み合わせは、そのままだとうまく動かず、出力がくずれてしまいます。

そこで、Railsのinitializerでwill_paginateをラップするヘルパーを設定する方法が紹介されています。

http://isaacbowen.com/blog/using-will_paginate-action_view-and-bootstrap/

が、今度はwii_paginateにワナがあり、上記initializerで上書きしようとしているクラスが外部からアクセスできません。

そこで、まわり回ってwii_paginateのバグレポートに到達。

https://github.com/mislav/will_paginate/issues/165

この情報を元に、initializerに下記の1行を追加する事でようやく問題を解決できました。

require ‘will_paginate/view_helpers/action_view’