x-editable-rails 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/x-editable-rails/version.rb +1 -1
- data/lib/x-editable-rails/view_helpers.rb +7 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f39c1375f2107089642f9db987497129da954a8
|
4
|
+
data.tar.gz: 8327e2d422935b22a68e3abb880e62c7a64684ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8443ec604c47018fac79f45674e3314a8d0579a9aadb8d4c7505d65147f645fb6b3919de927945753b4edf56837541ec9c52829628b29f3a672558b35fbe6cbc
|
7
|
+
data.tar.gz: 421750f2132b0eebeac8cbd5530de78826abad6e4744f284176d2fdbba84d91997f5f060d2dcf41394db79ab4388d75d0f11ade1d5272d86a57431964d3a0873
|
data/README.md
CHANGED
@@ -49,19 +49,19 @@ end
|
|
49
49
|
and this is how to use helper method
|
50
50
|
|
51
51
|
```ruby
|
52
|
-
%h1= editable
|
53
|
-
# editable
|
52
|
+
%h1= editable @page, 'name', e: @page.name
|
53
|
+
# editable object, what_you_want_update, e: exception - when is xeditable? false or can? :edit, object is false
|
54
54
|
```
|
55
55
|
|
56
56
|
or with nested attributes (globalize3 example)
|
57
57
|
```ruby
|
58
|
-
%h1= editable
|
58
|
+
%h1= editable @page, 'name', nested: 'translations', nid: @page.translation.id, e: @page.name
|
59
59
|
# nested: nested attributes, nid: id of nested attribute
|
60
60
|
```
|
61
61
|
|
62
62
|
Example of nested resource
|
63
63
|
```ruby
|
64
|
-
%h1= editable
|
64
|
+
%h1= editable [picture.gallery, picture], 'name', nested: 'translations', nid: picture.translation.id, e: picture.name
|
65
65
|
```
|
66
66
|
|
67
67
|
You can also update everything directly.
|
@@ -2,12 +2,13 @@ module X
|
|
2
2
|
module Editable
|
3
3
|
module Rails
|
4
4
|
module ViewHelpers
|
5
|
-
def editable
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
def editable object, method, options = {}
|
6
|
+
data_url = polymorphic_path(object)
|
7
|
+
object = object.last if object.kind_of?(Array)
|
8
|
+
if can? :edit, object and xeditable?
|
9
|
+
model = object.class.to_s.downcase
|
10
|
+
model_param = model.gsub('::', '_')
|
11
|
+
model_name = model.gsub('::', '/')
|
11
12
|
content_tag :a, href: "#", class: "editable", data: { type: 'text', model: model_param, name: method, url: data_url,
|
12
13
|
nested: (options[:nested] if options[:nested]), nid: (options[:nid] if options[:nid]), 'original-title' => t("activerecord.attributes.#{model_name}#{"/#{options[:nested].singularize}" if options[:nested]}.#{method}") } do
|
13
14
|
object.send(method)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: x-editable-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jiri Kolarik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|