Module: Decidim::ActionAuthorizationHelper

Included in:
ViewModel
Defined in:
app/helpers/decidim/action_authorization_helper.rb

Instance Method Summary collapse

Instance Method Details

#action_authorized_button_to(action, *arguments, &block) ⇒ Object

Public: Emulates a ‘button_to` but conditionally renders a popup modal blocking the action in case the user is not allowed to perform it.

action - The name of the action to authorize against. *arguments - A regular set of arguments that would be provided to

`button_to`.

Returns a String with the button.



25
26
27
# File 'app/helpers/decidim/action_authorization_helper.rb', line 25

def action_authorized_button_to(action, *arguments, &block)
  authorized_to(:button, action, arguments, block)
end

Public: Emulates a ‘link_to` but conditionally renders a popup modal blocking the action in case the user is not allowed to perform it.

action - The name of the action to authorize against. *arguments - A regular set of arguments that would be provided to

`link_to`.

Returns a String with the link.



13
14
15
# File 'app/helpers/decidim/action_authorization_helper.rb', line 13

def action_authorized_link_to(action, *arguments, &block)
  authorized_to(:link, action, arguments, block)
end

#logged_button_to(*arguments, &block) ⇒ Object

Public: Emulates a ‘button_to` but conditionally renders a popup modal blocking the action in case the user is not logged id.

*arguments - A regular set of arguments that would be provided to

`button_to`.

Returns a String with the button.



47
48
49
# File 'app/helpers/decidim/action_authorization_helper.rb', line 47

def logged_button_to(*arguments, &block)
  authorized_to(:button, nil, arguments, block)
end

Public: Emulates a ‘link_to` but conditionally renders a popup modal blocking the action in case the user is not logged id.

*arguments - A regular set of arguments that would be provided to

`link_to`.

Returns a String with the link.



36
37
38
# File 'app/helpers/decidim/action_authorization_helper.rb', line 36

def logged_link_to(*arguments, &block)
  authorized_to(:link, nil, arguments, block)
end