내가 만드는 새로운 user.My 컨트롤러 코드를 생성하기위한 PARAM 값에 액세스 할 수있는 작업ruby on rails에서 컨트롤러의 param 값에 액세스하는 방법은 무엇입니까?
def newstudent
@student = Student.new(params)
puts "+++++++++++"
puts params.inspect
if @student.save
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @jtable }
end
end
end
되어있어하지만이 작업을 수행하여 내가 terminal.It에서 일부 오류가이
ActiveModel::MassAssignmentSecurity::Error (Can't mass-assign protected attributes: action, controller):
app/controllers/students_controller.rb:42:in `new'
app/controllers/students_controller.rb:42:in `newstudent'
처럼 보여줍니다 가지고 있었다
문제를 해결하는 데 도움을 주시겠습니까?
폼 컨트롤러를 제출하면'id'.so 귀하의 경우는'@student = Student.find ([ID] PARAMS)처럼 할 수와 함께'create' 메소드를 호출 한 후 newstudent 메소드를 사용하여 새로운 레코드를 생성하면'@student = Student.new()'를 사용할 수 있습니다. –
나는 그것을 위해 soluton을 가지고 있었다. – Niths