LoginSignup
3
2

More than 5 years have passed since last update.

[小ネタ]Kaminariで行番号を表示する

Last updated at Posted at 2014-12-11

コントローラー内で

some_controller.rb
@anyresults = AnyModel.page(params[:page])`

のように結果セット@anyresultsを取得した場合viewで

some.html.slim
ul
  - @anyresults.each.with_index(1) do |anyresult, i|
    li = i + @anyresult.offset_value 
end

とすればよい。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2