employees.rb
1ActiveAdmin.register Employee do 2 permit_params :name, :department, :gender, :birth, :joined_date, :payment, :note 3end
vagrant@ubuntu-bionic:/vagrant/rails+vue$ rails g controller ApiController /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) from /var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/enum.rb:156:in `block in enum' from /var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/enum.rb:155:in `each' from /var/lib/gems/2.5.0/gems/activerecord-6.0.2.1/lib/active_record/enum.rb:155:in `enum' from /vagrant/rails+vue/app/models/employee.rb:4:in `<class:Employee>' from /vagrant/rails+vue/app/models/employee.rb:1:in `<top (required)>' 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' 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' from /var/lib/gems/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' 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' 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' from /var/lib/gems/2.5.0/gems/zeitwerk-2.2.2/lib/zeitwerk/kernel.rb:16:in `require' from /vagrant/rails+vue/app/admin/employees.rb:1:in `<top (required)>' 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' 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' from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin/application.rb:123:in `block in load' from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin/error.rb:43:in `capture' from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin/application.rb:123:in `load' from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin/application.rb:115:in `block in load!' from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin/application.rb:115:in `each' from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin/application.rb:115:in `load!' from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin/application.rb:141:in `routes' from /var/lib/gems/2.5.0/gems/activeadmin-2.6.0/lib/active_admin.rb:76:in `routes' from /vagrant/rails+vue/config/routes.rb:2:in `block in <top (required)>' from /var/lib/gems/2.5.0/gems/actionpack-6.0.2.1/lib/action_dispatch/routing/route_set.rb:429:in `instance_exec' from /var/lib/gems/2.5.0/gems/actionpack-6.0.2.1/lib/action_dispatch/routing/route_set.rb:429:in `eval_block' from /var/lib/gems/2.5.0/gems/actionpack-6.0.2.1/lib/action_dispatch/routing/route_set.rb:411:in `draw' from /vagrant/rails+vue/config/routes.rb:1:in `<top (required)>' ・・・
employee.rb
1class Employee < ApplicationRecord 2 GENDERS = { other: 0, male: 1, female: 2} 3 4 enum gender = GENDERS 5 6 validates :gender, inclusion: { in: GENDERS.key.concat(GENDERS.keys.map(&:to_s))}, exclusion: { in: [nil] } 7 validates :name, exclusion: { in: [nil, ""] } 8 validates :department, exclusion: { in: [nil] } 9 validates :payment, numericality: true, exclusion: { in: [nil] } 10 validates :note, exclusion: { in: [nil] } 11end
ActiveAdminを導入しマイグレーションをしたのですが、それ以降rails g controllerで新しいコントローラーを作ってもrails generate active_admin:resource EmployeeでモデルをActiveAdminでCRUDできるようなコマンドを打っても、bundle exec rails cを打っても画像のような同じエラーが出てしまいます。
確認をお願いします。
回答1件
あなたの回答
tips
プレビュー