質問編集履歴

2

失礼しました。変更しました。

2019/12/20 08:25

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -72,6 +72,32 @@
72
72
 
73
73
  ```
74
74
 
75
+ ```employee.rb
76
+
77
+ class Employee < ApplicationRecord
78
+
79
+ GENDERS = { other: 0, male: 1, female: 2}
80
+
81
+
82
+
83
+ enum gender = GENDERS
84
+
85
+
86
+
87
+ validates :gender, inclusion: { in: GENDERS.key.concat(GENDERS.keys.map(&:to_s))}, exclusion: { in: [nil] }
88
+
89
+ validates :name, exclusion: { in: [nil, ""] }
90
+
91
+ validates :department, exclusion: { in: [nil] }
92
+
93
+ validates :payment, numericality: true, exclusion: { in: [nil] }
94
+
95
+ validates :note, exclusion: { in: [nil] }
96
+
97
+ end
98
+
99
+ ```
100
+
75
101
  railsでhttps://qiita.com/tatsurou313/items/4f18c0d4d231e2fb55f4#%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E5%85%A8%E4%BD%93%E5%83%8Fこの記事に載っているアプリケーションを開発しています。
76
102
 
77
103
 

1

変更しました。上がemployees.rbで下がターミナルです。よろしくお願いいたします。

2019/12/20 08:25

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,77 @@
1
+ ```employees.rb
2
+
3
+ ActiveAdmin.register Employee do
4
+
5
+ permit_params :name, :department, :gender, :birth, :joined_date, :payment, :note
6
+
7
+ end
8
+
9
+ ```
10
+
11
+ ```ターミナル
12
+
13
+ vagrant@ubuntu-bionic:/vagrant/rails+vue$ rails g controller ApiController
14
+
15
+ /var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/enum.rb:227:in `assert_valid_enum_definition_values': undefined method `all?' for 0:Integer (NoMethodError)
16
+
17
+ from /var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/enum.rb:156:in `block in enum'
18
+
19
+ from /var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/enum.rb:155:in `each'
20
+
21
+ from /var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/enum.rb:155:in `enum'
22
+
23
+ from /vagrant/rails+vue/app/models/employee.rb:4:in `<class:Employee>'
24
+
25
+ from /vagrant/rails+vue/app/models/employee.rb:1:in `<top (required)>'
26
+
27
+ from /var/lib/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
28
+
29
+ from /var/lib/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
30
+
31
+ from /var/lib/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
32
+
33
+ from /var/lib/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
34
+
35
+ from /var/lib/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
36
+
37
+ from /var/lib/gems/2.5.0/gems/zeitwerk-2.2.2/lib/zeitwerk/kernel.rb:16:in `require'
38
+
39
+ from /vagrant/rails+vue/app/admin/employees.rb:1:in `<top (required)>'
40
+
41
+ from /var/lib/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
42
+
43
+ from /var/lib/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:54:in `load'
44
+
45
+ from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin/application.rb:123:in `block in load'
46
+
47
+ from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin/error.rb:43:in `capture'
48
+
49
+ from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin/application.rb:123:in `load'
50
+
51
+ from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin/application.rb:115:in `block in load!'
52
+
53
+ from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin/application.rb:115:in `each'
54
+
55
+ from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin/application.rb:115:in `load!'
56
+
57
+ from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin/application.rb:141:in `routes'
58
+
59
+ from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin.rb:76:in `routes'
60
+
61
+ from /vagrant/rails+vue/config/routes.rb:2:in `block in <top (required)>'
62
+
63
+ from /var/lib/gems/2.5.0/gems/actionpack-6.0.2.1/lib/action_dispatch/routing/route_set.rb:429:in `instance_exec'
64
+
65
+ from /var/lib/gems/2.5.0/gems/actionpack-6.0.2.1/lib/action_dispatch/routing/route_set.rb:429:in `eval_block'
66
+
67
+ from /var/lib/gems/2.5.0/gems/actionpack-6.0.2.1/lib/action_dispatch/routing/route_set.rb:411:in `draw'
68
+
69
+ from /vagrant/rails+vue/config/routes.rb:1:in `<top (required)>'
70
+
71
+ ・・・
72
+
73
+ ```
74
+
1
75
  railsでhttps://qiita.com/tatsurou313/items/4f18c0d4d231e2fb55f4#%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%81%AE%E5%85%A8%E4%BD%93%E5%83%8Fこの記事に載っているアプリケーションを開発しています。
2
76
 
3
77