reform-rails 0.1.3 → 0.1.4

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: 1400de06d17da697f8c4a7e86191ed5a39b4c6dc
4
- data.tar.gz: f64c23b9d6e57f89dcb5ab0fd5bba9cbe96163d3
3
+ metadata.gz: e2a4bb3a64ef4f53fe1a03d4886a84275cf77c05
4
+ data.tar.gz: be3cddbf1dcc890adf09373a14f2fbe1ba706c04
5
5
  SHA512:
6
- metadata.gz: 8f6a025bb35d41901c746733b40f1979f579c60ac21d38cb49212a545b7a17905b2c4880bfd3b8a12fc2f2682950b032359193b932d4ce6ad81d1e70dfbcf3c4
7
- data.tar.gz: 7429e04e455a6237f78019a41d04775ca4b2481c8ad5a9402979646c2b9472f1bd8d9a41e49fea3d63198316ce2bd026bc066a6c22ab2fdbea92bbe1b6a99419
6
+ metadata.gz: f84f21d50c895a1d2ee55befae0a9fa095951f03349a39b40817bd9ba7369332737c81dd7fbe53ef4e82e24bea24f762ee7ae1f68ac4159c181d44fd67bf4fb4
7
+ data.tar.gz: 5659e0a564452f062cb49983914f092255cd7abd2c850a59b9c59c6ba9a6ede7c21fac915aa1e6a3124b66218b38c630407a1b2290b69fe789b63b0c1910b2e2
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.1.4
2
+
3
+ * Allow setting `config.reform` in initializers, too.
4
+
1
5
  # 0.1.3
2
6
 
3
7
  * Introduce a railtie to load either `ActiveModel::Validations` *or* `Dry::Validations`. This can be controller via `config.reform.validations = :dry`.
data/README.md CHANGED
@@ -12,6 +12,10 @@ Loads Rails-specific Reform files and includes modules like `Reform::Form::Activ
12
12
 
13
13
  Simply don't include this gem if you don't want to use the conventional Reform/Rails stack. For example in a Hanami environment or when using dry-validations, refrain from using this gem.
14
14
 
15
+ ## Documentation
16
+
17
+ The [full documentation](http://trailblazer.to/gems/reform/#reform-rails) can be found on the Trailblazer page.
18
+
15
19
  ## Installation
16
20
 
17
21
  Add this line to your application's Gemfile:
Binary file
@@ -0,0 +1,26 @@
1
+ module Reform::Form::ORM
2
+ def model_for_property(name)
3
+ return model unless is_a?(Reform::Form::Composition) # i am too lazy for proper inheritance. there should be a ActiveRecord::Composition that handles this.
4
+
5
+ model_name = options_for(name)[:on]
6
+ model[model_name]
7
+ end
8
+
9
+ module UniquenessValidator
10
+ # when calling validates it should create the Vali instance already and set @klass there! # TODO: fix this in AM.
11
+ def validate(form)
12
+ property = attributes.first
13
+
14
+ # here is the thing: why does AM::UniquenessValidator require a filled-out record to work properly? also, why do we need to set
15
+ # the class? it would be way easier to pass #validate a hash of attributes and get back an errors hash.
16
+ # the class for the finder could either be infered from the record or set in the validator instance itself in the call to ::validates.
17
+ record = form.model_for_property(property)
18
+ record.send("#{property}=", form.send(property))
19
+
20
+ @klass = record.class # this is usually done in the super-sucky #setup method.
21
+ super(record).tap do |res|
22
+ form.errors.add(property, record.errors.first.last) if record.errors.present?
23
+ end
24
+ end
25
+ end
26
+ end
@@ -3,7 +3,7 @@ module Reform
3
3
  class Railtie < ::Rails::Railtie
4
4
  config.reform = ActiveSupport::OrderedOptions.new
5
5
 
6
- initializer "reform.form_extensions", before: :load_config_initializers do
6
+ initializer "reform.form_extensions", after: :load_config_initializers do
7
7
  validations = config.reform.validations || :active_model
8
8
 
9
9
  if validations == :active_model
@@ -1,5 +1,5 @@
1
1
  module Reform
2
2
  module Rails
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reform-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-30 00:00:00.000000000 Z
11
+ date: 2016-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reform
@@ -179,6 +179,7 @@ files:
179
179
  - lib/reform/form/active_model/validations.rb
180
180
  - lib/reform/form/active_record.rb
181
181
  - lib/reform/form/multi_parameter_attributes.rb
182
+ - lib/reform/form/orm.rb
182
183
  - lib/reform/form/validation/unique_validator.rb
183
184
  - lib/reform/rails.rb
184
185
  - lib/reform/rails/railtie.rb