To Examples

ValidationErrors Example

Source code file: ValidationErrors/app/students_controller.rb:

class StudentsController < ApplicationController

  def add_new
    @student = Student.new
  end

  def display_all
    @student = Student.new(post_params)
    @student.save
    @a = Student.all
  end

private

  def post_params
    params.require(:student).permit(
      :fname, :major, :year, :gpa)
  end

end