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 +4 -4
- data/CHANGES.md +4 -0
- data/README.md +4 -0
- data/database.sqlite3 +0 -0
- data/lib/reform/form/orm.rb +26 -0
- data/lib/reform/rails/railtie.rb +1 -1
- data/lib/reform/rails/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2a4bb3a64ef4f53fe1a03d4886a84275cf77c05
|
4
|
+
data.tar.gz: be3cddbf1dcc890adf09373a14f2fbe1ba706c04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f84f21d50c895a1d2ee55befae0a9fa095951f03349a39b40817bd9ba7369332737c81dd7fbe53ef4e82e24bea24f762ee7ae1f68ac4159c181d44fd67bf4fb4
|
7
|
+
data.tar.gz: 5659e0a564452f062cb49983914f092255cd7abd2c850a59b9c59c6ba9a6ede7c21fac915aa1e6a3124b66218b38c630407a1b2290b69fe789b63b0c1910b2e2
|
data/CHANGES.md
CHANGED
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:
|
data/database.sqlite3
CHANGED
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
|
data/lib/reform/rails/railtie.rb
CHANGED
@@ -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",
|
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
|
data/lib/reform/rails/version.rb
CHANGED
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.
|
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-
|
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
|