on_the_spot 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/on_the_spot/controller_extension.rb +13 -5
- data/on_the_spot.gemspec +3 -3
- 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: 51757cdc9d29fea0cfb496f571c20503bc18addd
|
4
|
+
data.tar.gz: c9abf4e102543f6b6ddcd0abac23348ea075a6a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c3372aab107fc7e35ec813171e2dcdf8176a4c37e8ed97838c36a19c0f91d1477927a44f3a29ee4576a5be00b37d9de24070d13e39321a6b79018a8e465c0c8
|
7
|
+
data.tar.gz: 92b672e3c547f22b8f6f931a96e7c14f466f30142cd96087e031c93915b2ce70558b1cbcf3ac29836282d9d7c16e0448f79284644406e358e010e6ae61c87223
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.6
|
@@ -10,16 +10,24 @@ module OnTheSpot
|
|
10
10
|
module ClassMethods
|
11
11
|
def can_edit_on_the_spot(check_acces_method=nil)
|
12
12
|
define_method :update_attribute_on_the_spot do
|
13
|
-
|
13
|
+
klass_name, field, id = params[:id].split('__')
|
14
14
|
select_data = params[:select_array]
|
15
15
|
display_method = params[:display_method]
|
16
16
|
|
17
|
-
|
17
|
+
klass = klass_name.camelize.constantize
|
18
|
+
object = klass.find(id)
|
18
19
|
|
19
20
|
is_allowed = check_acces_method.present? ? self.send(check_acces_method, object, field) : true
|
20
21
|
|
21
22
|
if is_allowed
|
22
|
-
if
|
23
|
+
saved = if klass.attribute_names.include?(field)
|
24
|
+
object.update_attributes(field => params[:value])
|
25
|
+
else
|
26
|
+
# calculated attribute?
|
27
|
+
object.send("#{field}=", params[:value])
|
28
|
+
object.save
|
29
|
+
end
|
30
|
+
if saved
|
23
31
|
if select_data.nil?
|
24
32
|
field_or_method = if display_method.present?
|
25
33
|
object.send(display_method)
|
@@ -41,9 +49,9 @@ module OnTheSpot
|
|
41
49
|
end
|
42
50
|
|
43
51
|
define_method :get_attribute_on_the_spot do
|
44
|
-
|
52
|
+
klass_name, field, id = params[:id].split('__')
|
45
53
|
|
46
|
-
object =
|
54
|
+
object = klass_name.camelize.constantize.find(id)
|
47
55
|
|
48
56
|
is_allowed = check_acces_method.present? ? self.send(check_acces_method, object, field) : true
|
49
57
|
|
data/on_the_spot.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: on_the_spot 1.0.
|
5
|
+
# stub: on_the_spot 1.0.6 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "on_the_spot"
|
9
|
-
s.version = "1.0.
|
9
|
+
s.version = "1.0.6"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Nathan Van der Auwera"]
|
14
|
-
s.date = "2017-
|
14
|
+
s.date = "2017-04-19"
|
15
15
|
s.description = "Unobtrusive in place editing, using jEditable; only works in Rails 3"
|
16
16
|
s.email = "nathan@dixis.com"
|
17
17
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: on_the_spot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Van der Auwera
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|