我正在用 Ruby 3 和 Rails 6.1 重写我用 Ruby 2.7 和 Rails 6.0 构建的项目。我正在使用 rails admin gem 以及 devise 和 cancancan。在我的旧项目中,创建一个简单的 EventCategory 对象没有问题。当我现在尝试时,我得到:
和:
Started POST "/admin/event_category/new" for ::1 at 2020-12-28 13:44:46 -0500
Processing by RailsAdmin::MainController#new as HTML
Parameters: {"authenticity_token"=>"[FILTERED]", "event_category"=>{"name"=>"Run", "description"=>"", "unit_of_measurement"=>""}, "return_to"=>"http://localhost:3000/u/sign_in", "_save"=>"", "model_name"=>"event_category"}
User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]]
↳ config/initializers/rails_admin.rb:7:in `block (2 levels) in <main>'
Completed 500 Internal Server Error in 6ms (ActiveRecord: 1.0ms | Allocations: 2754)
ArgumentError (wrong number of arguments (given 1, expected 0)):
activerecord (6.1.0) lib/active_record/suppressor.rb:43:in `save'
rails_admin (2.0.2) lib/rails_admin/adapters/active_record/abstract_object.rb:23:in `save'
rails_admin (2.0.2) lib/rails_admin/config/actions/new.rb:41:in `block (2 levels) in <class:New>'
rails_admin (2.0.2) app/controllers/rails_admin/main_controller.rb:22:in `instance_eval'
rails_admin (2.0.2) app/controllers/rails_admin/main_controller.rb:22:in `new'
这是我在 event_category.rb 中的模型
class EventCategory < ApplicationRecord
has_many :events
rails_admin do
edit do
field :name
field :description
field :unit_of_measurement
end
end
end
我真的很感激这个指导。