由于某些原因,在我当前的控制器中,我得到了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发布于 2013-10-18 18:55:23
我想你还没完全理解强对撞机的工作方式.
你有个方法
def heuristic_params
params.require(:heuristic).permit!
end而且你没有使用它
Heuristic.new(params[:heuristic])https://stackoverflow.com/questions/19456809
复制相似问题