Module: CanTango::Rails::Helpers::RestHelper
- Defined in:
- lib/cantango/rails/helpers/rest_helper.rb
Instance Method Summary collapse
- #link_to_delete(obj, user_type, options = {}) ⇒ Object
- #link_to_edit(obj, user_type, options = {}) ⇒ Object
- #link_to_new(obj, user_type, options = {}) ⇒ Object
- #link_to_view(obj, user_type, options = {}) ⇒ Object
Instance Method Details
#link_to_delete(obj, user_type, options = {}) ⇒ Object
40 41 42 43 44 |
# File 'lib/cantango/rails/helpers/rest_helper.rb', line 40 def link_to_delete obj, user_type, = {} return unless can_perform_action?(user_type, :delete, obj) # use i18n translation on label link_to t(".delete"), rest_obj_action(obj, :delete, ) end |
#link_to_edit(obj, user_type, options = {}) ⇒ Object
46 47 48 49 50 |
# File 'lib/cantango/rails/helpers/rest_helper.rb', line 46 def link_to_edit obj, user_type, = {} return unless can_perform_action?(user_type, :edit, obj) # use i18n translation on label link_to t(".edit"), rest_obj_action(obj, :edit, ) end |
#link_to_new(obj, user_type, options = {}) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/cantango/rails/helpers/rest_helper.rb', line 33 def link_to_new obj, user_type, = {} 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, ) end |
#link_to_view(obj, user_type, options = {}) ⇒ Object
52 53 54 55 56 |
# File 'lib/cantango/rails/helpers/rest_helper.rb', line 52 def link_to_view obj, user_type, = {} return unless can_perform_action?(user_type, :view, obj) # use i18n translation on label link_to t(".view"), send(view_method(obj), obj, ) end |