Module: Authz::Helpers::ViewHelpers

Defined in:
lib/authz/helpers/view_helpers.rb

Overview

View Helpers that are made available to the host application

Instance Method Summary collapse

Instance Method Details

Renders a link if user is authorized or does nothing otherwise

Parameters:

  • name (String)

    same as Rails link_to

  • options (Hash) (defaults to: {})

    same as Rails link_to

  • html_options (Hash) (defaults to: {})

    same as Rails link_to

  • using (Object) (defaults to: nil)

    instance that will be used to determine authorization

  • skip_scoping (Boolean) (defaults to: nil)

    option to skip scoping validation



12
13
14
15
16
17
# File 'lib/authz/helpers/view_helpers.rb', line 12

def authz_link_to(name, options = {}, html_options = {}, using: nil, skip_scoping: nil)
  url = url_for(options)
  method = html_options[:method] || html_options['method']
  authorized = authorized_path? url, method: method, using: using, skip_scoping: skip_scoping
  link_to(name, options, html_options) if authorized
end