Module: Tenon::BackToIndexPathHelper

Defined in:
app/helpers/tenon/back_to_index_path_helper.rb

Overview

Generate a back button that includes the previous query if there was one

Instance Method Summary collapse

Instance Method Details

#back_to_index_path(obj) ⇒ Object



4
5
6
7
8
9
10
11
# File 'app/helpers/tenon/back_to_index_path_helper.rb', line 4

def back_to_index_path(obj)
  path = polymorphic_path(obj.class)
  if cookies["last-query-#{path}.json"].present?
    query = JSON.parse(cookies["last-query-#{path}.json"])
    path = polymorphic_path(obj.class, query)
  end
  path
end