vue-rails-form-builder 0.5.0 → 0.6.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: eef8da7255dabca2715386145fcc26924d6c57d2
4
- data.tar.gz: cc4b535b836f76ebcc0da4e868f9db6be0e4456e
3
+ metadata.gz: 211bbcaf159e3c95ae46f5d35d0fba7832163dec
4
+ data.tar.gz: 28a332752a4d67590f813b093afd22d56e5a54fa
5
5
  SHA512:
6
- metadata.gz: 6ae0a9d420c239f59a6e50df6e89d5be1a540317a56db421ee5adc59d42e2b28c18fd68f27fc7bdc95406e1926f30cc2a428bbaaeec19427f182f63ee9b3a161
7
- data.tar.gz: 52a4b0bc39f1d19aeb18080a66220b85d687de7ee134f95eff16878897ad485c4bd9adace00b38a0662b1f92d594b6c5b0e3d6ba779f3c8fe8a8fdc9aba676be
6
+ metadata.gz: a07b28dcf78327fc6135f32ce14aacf1a8b1765272d45a4afc23c13317f39dbd187b13002e3de1156abefd575b1780223fb1a89088134f53155372dc41cc4a69
7
+ data.tar.gz: 298767defa387e395159788a5e94b00e4879b647f7e52aff9a598c96594cbc8d14060e9ca7e4fb9e10fef109aff70376ba230abff9027eaaf03393b037f65ecd
data/CHANGELOG.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # CHANGELOG - vue-rails-form-builder
2
2
 
3
+ ## 0.6.0 (2017-05-14)
4
+
5
+ * Add `vue_scope` option to `vue_form_for` and `vue_form_with` methods.
6
+
3
7
  ## 0.5.0 (2017-05-12)
4
8
 
5
- * Change the name of this gem to `vue-rails-form-builder` from `vue-form-for`
9
+ * Change the name of this gem to `vue-rails-form-builder` from `vue-form-for`.
6
10
 
7
11
  ## 0.4.0 (2017-05-11)
8
12
 
data/README.md CHANGED
@@ -83,6 +83,32 @@ Add this line to the ERB template:
83
83
 
84
84
  Then, you can get the value of `user[name]` field by the `user.name`.
85
85
 
86
+ If you use Rails 5.1 or above, you can also use `vue_form_with`:
87
+
88
+ ```erb
89
+ <%= vue_form_with model: User.new do |f| %>
90
+ <%= f.text_field :name %>
91
+ <%= f.submit "Create" %>
92
+ <% end %>
93
+ ```
94
+
95
+ Demo App
96
+ --------
97
+
98
+ Visit [vue-rails-form-builder-demo](https://github.com/kuroda/vue-rails-form-builder-demo)
99
+ for a working Rails demo application using the `vue-rails-form-builder`.
100
+
101
+ Options
102
+ -------
103
+
104
+ To `vue_form_for` and `vue_form_with` methods you can provide the same options
105
+ as `form_for` and `form_with`.
106
+
107
+ There is a special option:
108
+
109
+ * `:vue_scope` - The prefix used to the input field names within the Vue
110
+ component.
111
+
86
112
  Tag Helper
87
113
  ----------
88
114
 
@@ -215,7 +241,7 @@ in order to keep the original state of the form.
215
241
  License
216
242
  -------
217
243
 
218
- The `initial-test-data` is distributed under the MIT license. ([MIT-LICENSE](https://github.com/oiax/initial-test-data/blob/master/MIT-LICENSE))
244
+ The `vue-rails-form-builder` is distributed under the MIT license. ([MIT-LICENSE](https://github.com/kuroda/vue-rails-form-builder/blob/master/MIT-LICENSE))
219
245
 
220
246
  Author
221
247
  ------
@@ -1,5 +1,18 @@
1
1
  module VueRailsFormBuilder
2
2
  module FormHelper
3
+ def vue_form_with(**options)
4
+ unless respond_to?(:form_with)
5
+ raise "Your Rails does not implement form_with helper."
6
+ end
7
+
8
+ options[:builder] ||= VueRailsFormBuilder::FormBuilder
9
+ if block_given?
10
+ form_with(options, &Proc.new)
11
+ else
12
+ form_with(options)
13
+ end
14
+ end
15
+
3
16
  def vue_form_for(record, options = {}, &block)
4
17
  options[:builder] ||= VueRailsFormBuilder::FormBuilder
5
18
  form_for(record, options, &block)
@@ -40,8 +40,11 @@ module VueRailsFormBuilder
40
40
  end
41
41
 
42
42
  private def add_v_model_attribute(method, options)
43
- namespace = @object_name.gsub(/\[/, ".").gsub(/\]/, "")
44
- options[:"v-model"] ||= "#{namespace}.#{method}"
43
+ path = @object_name.gsub(/\[/, ".").gsub(/\]/, "").split(".")
44
+ if @options[:vue_scope]
45
+ path[0] = @options[:vue_scope]
46
+ end
47
+ options[:"v-model"] ||= (path + [ method ]).join(".")
45
48
  end
46
49
  end
47
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vue-rails-form-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tsutomu KURODA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-13 00:00:00.000000000 Z
11
+ date: 2017-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -50,8 +50,8 @@ dependencies:
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '6'
53
- description: 'This gem provides three view helpers for Rails app: vue_form_for, vue_tag,
54
- vue_content_tag.'
53
+ description: 'This gem provides four view helpers for Rails app: vue_form_with, vue_form_for,
54
+ vue_tag and vue_content_tag.'
55
55
  email: t-kuroda@oiax.jp
56
56
  executables: []
57
57
  extensions: []