通常、インデックスページには、フィルタリング、ページ、並べ替えのオプションがあります。新しい編集ページを表示した後、表示したのと同じオプションを使用してインデックスページに戻ることができます。
そのために、セッションでインデックスのパラメータを保存します。
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を使用していました。今、私はクッキーを使いたいです。したがって、セッションは軽くする必要があります。
そのような場合をどのように処理しますか?
ありがとう。
サム