Error when creating a new item in administration >> categories
Started POST "/enumerations" for 10.0.2.2 at 2016-08-02 17:11:14 +0800
Processing by EnumerationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"1y/MDFaS0y/kgNdIhnmJtilq1vzmJ7a/a7ULs6L7/
mYB80OLGXyN32vdR38dWEJGQXEkTLVbrb80wX6Uakw1vw==", "enumeration"=>{"type"=>"IssuePriority", "name"=>"1", "active"=>"1", "is_default"=>"0"}, "commit"=>"创建"}
Current user: admin (id=1)
WARNING: Can't mass-assign protected attributes for IssuePriority: type
lib/redmine/subclass_factory.rb:42:in `new_subclass_instance'
app/controllers/enumerations_controller.rb:93:in `build_new_enumeration'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
Completed 500 Internal Server Error in 37ms (ActiveRecord: 21.3ms)
ActiveRecord::StatementInvalid (Mysql2::Error: You can't specify target table 'enumerations' for update in FROM clause: UPDATE `enumerations` SET position = coalesce((
select position
from (select id, position from enumerations) as parent
where parent_id = parent.id), 1) WHERE `enumerations`.`type` IN ('IssuePriority') AND (`enumerations`.`parent_id` IS NOT NULL) ORDER BY `enumerations`.`position` ASC):
app/models/enumeration.rb:152:in `update_position'
app/controllers/enumerations_controller.rb:47:in `create'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
Please refer to https://stackoverflow.com/a/36432550