Noriyo Akita's Today I Learned

# 2024-05-27

Table of Contents

2024-05-27

kaminari gem の per はデフォルトで 25

https://github.com/kaminari/kaminari/blob/90715e7251346895d2c66eb3043433a635519074/kaminari-core/lib/kaminari/config.rb#L22-L24

Kaminari というモジュール内のクラス Config のイニシャライザでセットしている

def initialize
@default_per_page = 25

特異クラスの config メソッドで Config.new をセットしている

ブロック引数の config の属性に任意でセットすることができる

module Kaminari
# Configures global settings for Kaminari
# Kaminari.configure do |config|
# config.default_per_page = 10
# end
class << self
def configure
yield config
end
def config
@_config ||= Config.new
end
end
My avatar

Thanks for reading my blog post! Feel free to check out my other posts or contact me via the social links in the footer.


More Posts