0
通常,索引頁面有用於過濾,頁面,排序的選項。在顯示新的編輯頁面之後,您可能希望返回索引頁面,其中的選項與您看到的選項相同。在Rails中記錄索引參數的最好方法是什麼?
爲此,我在會話中保存索引的參數。
class ApplicationController < ActionController::Base
helper_method :index_with_params
after_filter :save_index_params, :only => [:index]
def save_index_params
session[self.class.to_s] = params
end
def index_with_params overrider={}
object = self.kind_of?(ApplicationController) ? self : controller
h = session[object.class.to_s] || {"action" => :index}
h["only_path"] = true
url_for(h.merge(overrider));
end
end
我曾經使用ActiveRecord進行會話存儲。現在我想使用cookie。所以會議應該很輕鬆。
你如何處理這種情況?
謝謝。
山姆