vanderleipinto/preparation_mentorship

Add field CNPJ in Supplier

Closed this issue · 1 comments

Add field CNPJ in Supplier

Add CNPJ to Supplier:

rails g migration AddCnpjToSuppliers cnpj:string

Migrate database.

rails db:migrate

Insert CNPJ field in the supplier form:

In the file: app/views/suppliers/_form.html.erb

  <div>
     <%= form.label :CNPJ, style: "display: block" %>
     <%= form.text_field :cnpj %>
  </div>

Allow the controller to receive CNPJ param.

In the file app/controllers/suppliers_controller.rb

...
    # Only allow a list of trusted parameters through.
    def supplier_params
      params.require(:supplier).permit(:name, :cnpj)
    end
...