on_the_spot 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c78dbcfeaf98cd5778045da66e017bc531291792
4
- data.tar.gz: 10bf21a021d803d15d58ac35b368dd8a307add24
3
+ metadata.gz: 51757cdc9d29fea0cfb496f571c20503bc18addd
4
+ data.tar.gz: c9abf4e102543f6b6ddcd0abac23348ea075a6a6
5
5
  SHA512:
6
- metadata.gz: 9a6ec871b36e4c80080c4f67f253bba42a50eeb10dee922fb60d309408a4d20578c7842721387fc0f4cb2501a91c8cc60dd9a28263e3d44511821673ce6fd5d5
7
- data.tar.gz: 10cac80a72071fbdeb16a404262a0fd31593c23ffcdc1363affeba5b7f8c3687fc4a8a64bdddca79123e67ac07636cd664447f7e090428911b342d9ca8f0e052
6
+ metadata.gz: 2c3372aab107fc7e35ec813171e2dcdf8176a4c37e8ed97838c36a19c0f91d1477927a44f3a29ee4576a5be00b37d9de24070d13e39321a6b79018a8e465c0c8
7
+ data.tar.gz: 92b672e3c547f22b8f6f931a96e7c14f466f30142cd96087e031c93915b2ce70558b1cbcf3ac29836282d9d7c16e0448f79284644406e358e010e6ae61c87223
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.5
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
- klass, field, id = params[:id].split('__')
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
- object = klass.camelize.constantize.find(id)
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 object.update_attributes(field => params[:value])
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
- klass, field, id = params[:id].split('__')
52
+ klass_name, field, id = params[:id].split('__')
45
53
 
46
- object = klass.camelize.constantize.find(id)
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
 
@@ -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 ruby lib
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.5"
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-01-10"
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.5
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-01-10 00:00:00.000000000 Z
11
+ date: 2017-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec