質問編集履歴
6
test
CHANGED
File without changes
|
test
CHANGED
@@ -23,6 +23,8 @@
|
|
23
23
|
class Work < ApplicationRecord
|
24
24
|
|
25
25
|
|
26
|
+
|
27
|
+
has_rich_text :content
|
26
28
|
|
27
29
|
has_many_attached :content
|
28
30
|
|
5
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,23 +32,23 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
-
def include_blob
|
35
|
+
def include_blob
|
36
36
|
|
37
|
-
if content.attached?
|
37
|
+
if content.attached?
|
38
38
|
|
39
|
-
if !['.jpg', '.png', '.gif'].include?(content.blob.content_type)
|
39
|
+
if !['.jpg', '.png', '.gif'].include?(content.blob.content_type)
|
40
40
|
|
41
|
-
errors.add(:content, I18n.t('errors.messages.file_type_not_image'))
|
41
|
+
errors.add(:content, I18n.t('errors.messages.file_type_not_image'))
|
42
42
|
|
43
|
-
elsif file.size > 10.megabyte
|
43
|
+
elsif file.size > 10.megabyte
|
44
44
|
|
45
|
-
errors.add(:content, I18n.t('errors.messages.file_size_over'))
|
45
|
+
errors.add(:content, I18n.t('errors.messages.file_size_over'))
|
46
46
|
|
47
|
-
end
|
47
|
+
end
|
48
48
|
|
49
|
-
end
|
49
|
+
end
|
50
50
|
|
51
|
-
end
|
51
|
+
end
|
52
52
|
|
53
53
|
|
54
54
|
|
4
インデント
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,23 +30,25 @@
|
|
30
30
|
|
31
31
|
validate :include_blob
|
32
32
|
|
33
|
-
|
33
|
+
|
34
34
|
|
35
|
-
|
35
|
+
def include_blob
|
36
36
|
|
37
|
-
|
37
|
+
if content.attached?
|
38
38
|
|
39
|
-
|
39
|
+
if !['.jpg', '.png', '.gif'].include?(content.blob.content_type)
|
40
40
|
|
41
|
-
|
41
|
+
errors.add(:content, I18n.t('errors.messages.file_type_not_image'))
|
42
42
|
|
43
|
-
|
43
|
+
elsif file.size > 10.megabyte
|
44
44
|
|
45
|
-
e
|
45
|
+
errors.add(:content, I18n.t('errors.messages.file_size_over'))
|
46
|
-
|
47
|
-
end
|
48
46
|
|
49
47
|
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
50
52
|
|
51
53
|
|
52
54
|
|
3
s
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
def include_blob
|
34
34
|
|
35
|
-
if content.
|
35
|
+
if content.attached?
|
36
36
|
|
37
37
|
if !['.jpg', '.png', '.gif'].include?(content.blob.content_type)
|
38
38
|
|
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
elsif file.size > 10.megabyte
|
42
42
|
|
43
|
-
errors.add(:content, I18n.t('errors.messages.file_
|
43
|
+
errors.add(:content, I18n.t('errors.messages.file_size_over'))
|
44
44
|
|
45
45
|
end
|
46
46
|
|
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,17 +30,17 @@
|
|
30
30
|
|
31
31
|
validate :include_blob
|
32
32
|
|
33
|
-
|
33
|
+
def include_blob
|
34
34
|
|
35
|
-
|
35
|
+
if content.value.attached?
|
36
36
|
|
37
|
-
|
37
|
+
if !['.jpg', '.png', '.gif'].include?(content.blob.content_type)
|
38
38
|
|
39
|
-
|
39
|
+
errors.add(:content, I18n.t('errors.messages.file_type_not_image'))
|
40
40
|
|
41
|
-
|
41
|
+
elsif file.size > 10.megabyte
|
42
42
|
|
43
|
-
|
43
|
+
errors.add(:content, I18n.t('errors.messages.file_type_not_image'))
|
44
44
|
|
45
45
|
end
|
46
46
|
|
1
コードタグの挿入
test
CHANGED
File without changes
|
test
CHANGED
@@ -15,6 +15,8 @@
|
|
15
15
|
|
16
16
|
|
17
17
|
### 該当のソースコード
|
18
|
+
|
19
|
+
```Ruby
|
18
20
|
|
19
21
|
|
20
22
|
|
@@ -50,6 +52,12 @@
|
|
50
52
|
|
51
53
|
end
|
52
54
|
|
55
|
+
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
|
60
|
+
|
53
61
|
### 試したこと
|
54
62
|
|
55
63
|
|