vanderleipinto / preparation_mentorship

0 stars 0 forks source link

feat: Add field CNPJ in Supplier #30

Closed vanderleipinto closed 9 months ago

vanderleipinto commented 9 months ago

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
...