A
A
Anton2015-12-01 22:13:15
Ruby on Rails
Anton, 2015-12-01 22:13:15

How to fix ActiveRecord::DangerousAttributeError?

Hello!
When submitting the form, this error pops up:
06450daf0f034e17b21f9060ac589fa0.png
Here is student_controller.rb:

class StudentController < ApplicationController
  def index
  end

  def registration
    # @student = Student.new
  end

  def create
    @student = Student.new(student_params)
  end

  private def student_params
    params.require(:student).permit(:first_name)
  end
end

To be honest, I have no idea what the error is about. As I understand it, DangerousAttributeError speaks of some dangerous attributes. I translated the second line describing the essence of the problem, but did not understand it.
In general, explain to me, please, what exactly is the problem here?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
N. Bekseitov, 2015-12-02
@nbekseitov

If the student has a hash attribute, rename it.

P
Pavel Grudinkin, 2015-12-01
@Hunt666

api.rubyonrails.org/classes/ActiveRecord/Dangerous...
Apparently first_name is reserved in ActiveRecord, try renaming it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question