x-editable-rails 1.0.3 → 1.1.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 +5 -0
- data/lib/x-editable-rails/version.rb +2 -2
- data/lib/x-editable-rails/view_helpers.rb +2 -1
- 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: c93848fb0c32466ffce4502e3aead74af7d39b99
|
4
|
+
data.tar.gz: 636c74b1410daaca83d67190f62933b4dfca8b78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a081571397867d85072c2b235c5cd18190283f205723a0e551e17a2d215c3180f4cc4d83a2e83a3ddf8277af0e191b86f99370de6b2947fcbf46d0292c69663
|
7
|
+
data.tar.gz: 4a0979504d966ec5eaa1fa188a140fd3977e2aebf8569e7a2ef54bfdb7a95d5acea87eb9cbae147cf05a847a0b241363e5b2d3876ccfe2d523acb4656e1f65da
|
data/README.md
CHANGED
@@ -59,6 +59,11 @@ or with nested attributes (globalize3 example)
|
|
59
59
|
# nested: nested attributes, nid: id of nested attribute
|
60
60
|
```
|
61
61
|
|
62
|
+
Example of nested resource
|
63
|
+
```ruby
|
64
|
+
%h1= editable Picture, [picture.gallery, picture], 'name', nested: 'translations', nid: picture.translation.id, e: picture.name
|
65
|
+
```
|
66
|
+
|
62
67
|
You can also update everything directly.
|
63
68
|
```haml
|
64
69
|
%a{href: '#', class: 'editable', data: { type: 'text', model: 'post', name: 'name', url: post_path(post), 'original-title' => 'Your info here'}}= post.name
|
@@ -4,9 +4,10 @@ module X
|
|
4
4
|
module ViewHelpers
|
5
5
|
def editable model, object, method, options = {}
|
6
6
|
if can? :edit, model and xeditable?
|
7
|
+
data_url = polymorphic_path(object)
|
8
|
+
object = object.last if object.kind_of?(Array)
|
7
9
|
model_param = model.to_s.downcase.gsub('::', '_')
|
8
10
|
model_name = model.to_s.downcase.gsub('::', '/')
|
9
|
-
data_url = options[:nested_model] ? polymorphic_path([options[:nested_model], object]) : polymorphic_path(object)
|
10
11
|
content_tag :a, href: "#", class: "editable", data: { type: 'text', model: model_param, name: method, url: data_url,
|
11
12
|
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
|
12
13
|
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.0
|
4
|
+
version: 1.1.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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|