kirico 1.0.3 → 1.0.4

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: 1bd3fdf27b6d6aebd713b76d264b08069b8fd0b7
4
- data.tar.gz: 46f10fe4947ce1d71027ad9928054fec18060de4
3
+ metadata.gz: 28534524bcc437fdf758e1d22da04ec2466196b0
4
+ data.tar.gz: cf58e75afffd2437f309309a0c94c270322bbb3f
5
5
  SHA512:
6
- metadata.gz: f8d773207b151e65fdf706c280687c3cdd449a95b34f44898f5dbb13637b46b5c5e05d343d3843276585fb6148094144477940b6eb96c940a9ea9b1d34f98c82
7
- data.tar.gz: e50e337487c3241ef1dd453d7f37aa5cec67cbfcd8bdb3dfafe1d7d046e48bf4bed196a0401fb0fde56d2af66858a35214c9da7baebd78677bca8c13501c8eb6
6
+ metadata.gz: a4a204454daf43b2e2817a0f75ce67f5bdfd9fe6b08be3bea6fc3023e70c09ba8e574c4d1c6d5d299d2caaf4ec926a1fb1d51be0fe85602bf6a569ca2594265e
7
+ data.tar.gz: 7f46f860418f9bd7da4906d867420bee5ab507dfc3943d624985889bdb7f00d11adb627572c7792f33e039b17f897ce59103d1add80a2e9782e784581550249f
@@ -1,5 +1,6 @@
1
1
  en:
2
2
  errors:
3
+ row_counter: "Row %{num}: "
3
4
  messages:
4
5
  invalid_charset: "has invalid character(s): %{error_chars}"
5
6
  invalid_space_divider: "must be dividied by %{space_type}"
@@ -1,5 +1,6 @@
1
1
  ja:
2
2
  errors:
3
+ row_counter: "%{num}行目: "
3
4
  messages:
4
5
  invalid_charset: "に利用できない文字が入力されています。%{error_chars}"
5
6
  invalid_space_divider: "は%{space_type}で区切ってください。"
@@ -40,13 +40,20 @@ module Kirico
40
40
 
41
41
  # 子のエラーを自身のエラーとして設定する
42
42
  def validate_children
43
- [:fd, :company, :company_count, :records].each do |attribute|
44
- records = [send(attribute)].flatten.compact
45
- records.each do |rec|
46
- next if rec.valid?
47
- rec.errors.full_messages.each do |msg|
48
- errors.add(attribute, msg)
49
- end
43
+ [:fd, :company, :company_count].each do |attribute|
44
+ rec = send(attribute)
45
+ next if rec.nil? || rec.valid?
46
+ rec.errors.full_messages.each do |msg|
47
+ errors.add(attribute, msg)
48
+ end
49
+ end
50
+
51
+ # 2行以上存在する場合は、何行目でエラーが起きたのかを知りたい
52
+ records.each.with_index(1) do |rec, i|
53
+ next if rec.valid?
54
+ row = I18n.t('errors.row_counter', num: i) if records.length > 1
55
+ rec.errors.full_messages.each do |msg|
56
+ errors.add(:records, "#{row}#{msg}")
50
57
  end
51
58
  end
52
59
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kirico
3
- VERSION = '1.0.3'
3
+ VERSION = '1.0.4'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kirico
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - kakipo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-19 00:00:00.000000000 Z
11
+ date: 2017-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport