class StudentsController < ApplicationController
def new @student = Student.new
end
def create @student = Student.new(params[:student])
if @student.save
redirect_to new_student_path
end
end
end
Since Rails 4, you couldn’t just forward a complete params hash to your
model. You could but you have to deactivate Strong Parameters before.
Anyways, I highly recommend you to follow this practices since your
approach opens a really big vulnerability.
For example:
You have an attribute “role” in your model. The user just have to add
the
attribute “role” to the parameters and is able to modify this protected
attribute.
Happy coding
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.