由于某种原因,在我当前的控制器中,我得到了 ActiveModel::ForbiddenAttributesError,即使我相信我使用强参数就好了。尽管我正在使用许可证!暂时允许所有模型属性。请参阅下面的代码,我错过了什么
class HeuristicsController < ApplicationController
def index
@heuristics = Heuristic.order(:name).page params[:page]
@heuristic = Heuristic.new
end
def create
@heuristic = Heuristic.new(params[:heuristic])
if @heuristic.save
redirect_to action: 'index', :flash => {:success => "New heuristic created!" }
else
render 'new'
end
end
def new
@title = "Heuristic"
@heuristic = Heuristic.new
end
private
def heuristic_params
params.require(:heuristic).permit!
end
end