0
我發現活動腳手架的配置「list.per_page」,但我可以讓用戶輸入他想要列出的記錄數。活動腳手架如何列出每個頁面在Rails 3中動態顯示的記錄數3
我想要一些動態的,因爲「list.per_page」是一個靜態量。
有人如何知道這樣做?您需要dinamically設置
我發現活動腳手架的配置「list.per_page」,但我可以讓用戶輸入他想要列出的記錄數。活動腳手架如何列出每個頁面在Rails 3中動態顯示的記錄數3
我想要一些動態的,因爲「list.per_page」是一個靜態量。
有人如何知道這樣做?您需要dinamically設置
任何活性的支架結構中,可以使用的before_filter(或before_action在導軌4):
DEFAULT_LENGTH = 30
before_filter :set_list_length
def set_list_length
length = @current_user.settings.per_page || DEFAULT_LENGTH
active_scaffold_config.list.per_page
# you can set here almost anything you want from AS config using active_scaffold_config and @current_user
end