I got a task to access param values for creating new user.My controller code for create is
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
But by doing this i had got some error in terminal.It shows like this
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'
Please help me to solve the problem?
This is my controller for add new student. By getting that error message you must reject controller and action using
@student = Student.new(params.reject {|key,value| key =="controller" || key =="action"})code.