class Oregano < ApplicationRecord
attr_protected :person_id
end
这使我误以为是
/activerecord-5.0.5/lib/active_record/dynamic_matchers.rb:21:in `method_missing': undefined method `attr_protected' for #<Class:0x000055b38448bd58> (NoMethodError).
为此,Rails 5升级中的替代品应该是什么?
不要在模型中使用attr_protected:person_id,而应使用强参数。您将在OreganosController中执行此操作:
def oregano_params
params.require(:oregano).permit(:person_id)
end