Module: ActionInterceptor::Common

Included in:
Controller, View
Defined in:
lib/action_interceptor/common.rb

Instance Method Summary collapse

Instance Method Details

#url_for(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/action_interceptor/common.rb', line 4

def url_for(options = {})
  url = super
  return url unless use_interceptor

  @interceptor_url_for_hash ||= is_interceptor ? \
                                intercepted_url_hash : current_url_hash

  uri = URI(url)
  new_query = URI.decode_www_form(uri.query || '') + \
                @interceptor_url_for_hash.to_a
  uri.query = URI.encode_www_form(new_query)
  uri.to_s
end