link_to_action 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/lib/link_to_action/locale/en.yml +4 -1
- data/lib/link_to_action/version.rb +1 -1
- data/lib/link_to_action.rb +14 -3
- metadata +2 -2
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Set of helpers: link_to_new, link_to_edit, link_to_destroy
|
4
4
|
|
5
|
-
|
5
|
+
Bonus helper: link_to_back
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
link_to_{action} object, options
|
23
|
+
link_to_{action} object, options
|
24
24
|
|
25
25
|
## Contributing
|
26
26
|
|
data/lib/link_to_action.rb
CHANGED
@@ -12,17 +12,28 @@ module LinkToAction
|
|
12
12
|
link_to_action(:edit, object, options)
|
13
13
|
end
|
14
14
|
|
15
|
+
def link_to_destroy(object, options = {})
|
16
|
+
options[:method] = :delete
|
17
|
+
options[:data] = { :confirm => t(:'helpers.link_to.destroy_confirm') }
|
18
|
+
options['data-skip-pjax'] = true
|
19
|
+
link_to_action(:destroy, object, options)
|
20
|
+
end
|
21
|
+
|
22
|
+
def link_to_back(options = {})
|
23
|
+
ilink_to 'undo large', t(:'helpers.link_to.back'), :back, options
|
24
|
+
end
|
25
|
+
|
15
26
|
private
|
16
27
|
|
17
|
-
ICONS = {new: 'plus', edit: 'edit'}
|
28
|
+
ICONS = {new: 'plus', edit: 'edit', destroy: 'trash'}
|
18
29
|
|
19
30
|
def link_to_action(action, object, options)
|
20
31
|
name = options.delete(:name) || t_action(object, action)
|
21
32
|
params = options.delete(:params) || {}
|
22
|
-
params[:action] = action
|
33
|
+
params[:action] = action if [ :new, :edit ].include? action
|
23
34
|
# TODO: make icon and can? optional
|
24
35
|
ilink_to "#{LinkToAction::ICONS[action]} large", name,
|
25
|
-
|
36
|
+
polymorphic_path(object, params), options if can?(action, object)
|
26
37
|
end
|
27
38
|
|
28
39
|
def ilink_to(*args)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: link_to_action
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: link_to for specific actions
|
15
15
|
email:
|