Class: SecureLink::Button

Inherits:
Object
  • Object
show all
Defined in:
lib/secure_link/button.rb

Instance Method Summary collapse

Instance Method Details

#button_to_secured(name, options = {}, html_options = nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/secure_link/button.rb', line 3

def button_to_secured(name, options = {}, html_options = nil)
  url = url_for(options)
  check_url = url

  unless ENV["RAILS_RELATIVE_URL_ROOT"].blank?
    check_url = check_url.gsub(ENV["RAILS_RELATIVE_URL_ROOT"], "")
  end

  method = html_options ? html_options[:method] : nil

  if authorized?(check_url, method)
    return button_to_open(name, url, html_options)
  end

  return ""
end