activeadmin-reform 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a305e245d1e8f6ac3758c1bf7ea2322d7c8a660
4
- data.tar.gz: e846405d5c62de356d0ba89f229d3c55b62575e4
3
+ metadata.gz: 9fb5f1cb1e6a8849bfe291cb6cf6ae4677ad0b84
4
+ data.tar.gz: 1d26346817eae70a0132331bae9ef65f914225c7
5
5
  SHA512:
6
- metadata.gz: 6562a54f864439d160273ae06d9cf4d5cf57a1afa12cd5156f024df015e99be65143a17c8d2369da642283325115dbb24383f767b65d7bc8ce6e0adba21e60b4
7
- data.tar.gz: 1a1834ae1d33b0b6568ff450aaec0e97502f28d5bf2d69b27bcc26012a17aa6e65423fbc065c54ec02ce56336e24d81bd3e8c191fb491164588836b8d60ca4cc
6
+ metadata.gz: b54c9baa7fa35c78ff9649a6ad4f209e1185695e1b1816a2a6c7335ec191cca72f487a8070c3ce490eccd565c0ecee03630343e7880eb65ba05f27fb9037f31e
7
+ data.tar.gz: 2a3423e2ce7058c30652915c1299c42c22e560484f22f0815a22e53d252b82cd064a240cc878b0564f98f48a34a370b06d716f3da8968cbb1462db1a1663b471
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --format documentation
2
2
  --color
3
+ --require spec_helper
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.3.0
2
+
3
+ * Form pre-population from URL parameters in ActiveAdmin controllers
4
+
1
5
  # 0.2.1
2
6
 
3
7
  * Copy validation errors from ActiveRocord model to Reform, thus in case of such errors they are shown on edit/new pages.
data/README.md CHANGED
@@ -30,12 +30,16 @@ Or install it yourself as:
30
30
 
31
31
  ## Usage
32
32
 
33
- Define your from object
33
+ Define your form object and include our mixin (`ActiveAdmin::Reform::ActiveRecord`) into it:
34
34
 
35
35
  ```ruby
36
36
  require 'reform'
37
37
 
38
38
  class AuthorForm < Reform::Form
39
+ include ActiveAdmin::Reform::ActiveRecord
40
+
41
+ model :author
42
+
39
43
  property :last_name, validates: { presence: true }
40
44
  property :name
41
45
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'activeadmin-reform'
7
- spec.version = '0.2.1'
7
+ spec.version = '0.3.0'
8
8
  spec.authors = ['Artyom Bolshakov']
9
9
  spec.email = ['abolshakov@spbtv.com']
10
10
 
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency 'rails', '>= 3.2'
22
22
  spec.add_dependency 'disposable', '>= 0.2.0'
23
23
  spec.add_dependency 'reform', '~> 2.2.1'
24
- spec.add_dependency 'reform-rails'
24
+ spec.add_dependency 'reform-rails', '~> 0.1.7'
25
25
  spec.add_development_dependency 'bundler', '~> 1.10'
26
26
  spec.add_development_dependency 'rake', '~> 10.0'
27
27
  spec.add_development_dependency 'rspec', '~> 3.4'
@@ -10,12 +10,20 @@ module ActiveAdmin
10
10
 
11
11
  delegate :new_record?, to: :model
12
12
 
13
- def save_model
14
- super.tap do
13
+ # @return [Boolean]
14
+ # Used here - https://github.com/activeadmin/activeadmin/blob/487f976/lib/active_admin/resource_controller/data_access.rb#L160
15
+ def save
16
+ validate({}) && super.tap do
15
17
  errors.merge!(model.errors, [])
16
18
  end
17
19
  end
18
20
 
21
+ # @param attributes [Hash]
22
+ # Used here - https://github.com/activeadmin/activeadmin/blob/487f976/lib/active_admin/resource_controller/data_access.rb#L301
23
+ def assign_attributes(attributes)
24
+ deserialize(attributes)
25
+ end
26
+
19
27
  included do
20
28
  include ::Reform::Form::ModelReflections
21
29
  include ::Reform::Form::ActiveRecord
@@ -16,31 +16,6 @@ module ActiveAdmin
16
16
  def apply_decorations(_resource)
17
17
  apply_form(super)
18
18
  end
19
-
20
- # @param resource [ActiveRecord::Base, Reform::Form]
21
- # @param attributes [(Hash)]
22
- # @return [ActiveRecord::Base, Reform::Form]
23
- def assign_attributes(resource, attributes)
24
- if resource.is_a?(::Reform::Form)
25
- resource.validate(*attributes) unless %w(new edit).include?(action_name)
26
- resource
27
- else
28
- super
29
- end
30
- end
31
-
32
- # Calls all the appropriate callbacks and then saves the new resource.
33
- #
34
- # @param [ActiveRecord::Base] object The new resource to save
35
- #
36
- # @return [void]
37
- def save_resource(object)
38
- if resource.is_a?(::Reform::Form)
39
- super unless object.errors.any?
40
- else
41
- super
42
- end
43
- end
44
19
  end
45
20
 
46
21
  ::ActiveAdmin::ResourceController.send(:include, DataAccess)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-reform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artyom Bolshakov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-04 00:00:00.000000000 Z
11
+ date: 2016-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: reform-rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.1.7
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 0.1.7
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  version: '0'
176
176
  requirements: []
177
177
  rubyforge_project:
178
- rubygems_version: 2.4.5.1
178
+ rubygems_version: 2.5.1
179
179
  signing_key:
180
180
  specification_version: 4
181
181
  summary: Integrates ActiveAdmin with Reform