Module: CanTango::Rails::Helpers::RestHelper

Defined in:
lib/cantango/rails/helpers/rest_helper.rb

Instance Method Summary collapse

Instance Method Details



17
18
19
20
21
# File 'lib/cantango/rails/helpers/rest_helper.rb', line 17

def link_to_delete obj, user_type, options = {}
  return unless can_perform_action?(user_type, :delete, obj)
  # use i18n translation on label
  link_to t(".delete"), rest_obj_action(obj, :delete, options)
end


23
24
25
26
27
# File 'lib/cantango/rails/helpers/rest_helper.rb', line 23

def link_to_edit obj, user_type, options = {}
  return unless can_perform_action?(user_type, :edit, obj)
  # use i18n translation on label
  link_to t(".edit"), rest_obj_action(obj, :edit, options)
end


10
11
12
13
14
15
# File 'lib/cantango/rails/helpers/rest_helper.rb', line 10

def link_to_new obj, user_type, options = {}
  clazz = obj.kind_of?(Class) ? obj : obj.class
  return unless can_perform_action?(user_type, :create, clazz)
  # use i18n translation on label
  link_to t(".create"), send(action_method clazz, :new, options)
end


29
30
31
32
33
# File 'lib/cantango/rails/helpers/rest_helper.rb', line 29

def link_to_view obj, user_type, options = {}
  return unless can_perform_action?(user_type, :view, obj)
  # use i18n translation on label
  link_to t(".view"), send(view_method(obj), obj, options)
end