Module: LinkToAction::Helpers
- Defined in:
- lib/link_to_action/helpers.rb
Instance Method Summary collapse
- #link_to_back(options = {}) ⇒ Object
- #link_to_destroy(object, options = {}) ⇒ Object
- #link_to_edit(object, options = {}) ⇒ Object
- #link_to_index(object, options = {}) ⇒ Object
- #link_to_new(object, options = {}) ⇒ Object
- #link_to_show(object, options = {}) ⇒ Object
Instance Method Details
#link_to_back(options = {}) ⇒ Object
37 38 39 |
# File 'lib/link_to_action/helpers.rb', line 37 def link_to_back( = {}) link_to_action :back, nil, end |
#link_to_destroy(object, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/link_to_action/helpers.rb', line 18 def link_to_destroy(object, = {}) [:method] = :delete if (.has_key? :confirm) confirm = .delete(:confirm) else confirm = LinkToAction.destroy_confirm end if confirm if confirm.kind_of?(String) confirm_text = confirm else confirm_text = t(:'helpers.link_to.destroy_confirm') end [:data] = { :confirm => confirm_text } end ['data-skip-pjax'] = true if LinkToAction.destroy_skip_pjax link_to_action(:destroy, object, ) end |
#link_to_edit(object, options = {}) ⇒ Object
14 15 16 |
# File 'lib/link_to_action/helpers.rb', line 14 def link_to_edit(object, = {}) link_to_action(:edit, object, ) end |
#link_to_index(object, options = {}) ⇒ Object
10 11 12 |
# File 'lib/link_to_action/helpers.rb', line 10 def link_to_index(object, = {}) link_to_action(:index, object, ) end |
#link_to_new(object, options = {}) ⇒ Object
6 7 8 |
# File 'lib/link_to_action/helpers.rb', line 6 def link_to_new(object, = {}) link_to_action(:new, object, ) end |
#link_to_show(object, options = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/link_to_action/helpers.rb', line 41 def link_to_show(object, = {}) name = .delete(:name) raw = .delete(:raw) send = .delete(:send) i18n = .delete(:i18n) unless name or i18n method = raw || send || LinkToAction.show_methods.find { |m| object.respond_to?(m) } name = object.send(method) name = raw(name) if raw end if i18n [:name] = name link_to_action :show, object, else link_to name, object, end end |