Si bien desde la presentaciòn de la interfaz esto no puede ocurrir, un usuario del sitio podrìa borrar esos campos del formulario (alterando el DOM) o realizar un post a mano sin el id de la persona o el cliente. Luego, al intentar guardar el objeto se genera un error colateral:
Started GET "/bills/31" for 127.0.0.1 at 2016-01-11 13:47:24 -0300
Processing by BillsController#show as HTML
Parameters: {"id"=>"31"}
Bill Load (0.6ms) SELECT "bills".* FROM "bills" WHERE "bills"."id" = ? LIMIT 1 [["id", 31]]
Rendered bills/show.html.erb within layouts/application (23.1ms)
Completed 500 Internal Server Error in 69ms (ActiveRecord: 0.6ms)
ActionView::Template::Error (undefined method `name' for nil:NilClass):
1: <dl class="dl-horizontal">
2: <dt>Cliente:<dt>
3: <dd class="text-capitalize"><%= "#{@bill.client.name} #{@bill.client.surname}" %></dd>
4:
5: <dt>CUIT/CUIL del cliente:<dt>
6: <dd><%= @bill.client.cui %></dd>
app/views/bills/show.html.erb:3:in `_app_views_bills_show_html_erb___450774075881403367_70241496514760'
Dado que la factura carece de cliente, al preguntarle el nombre a este ùltimo explota.
Si bien desde la presentaciòn de la interfaz esto no puede ocurrir, un usuario del sitio podrìa borrar esos campos del formulario (alterando el DOM) o realizar un post a mano sin el id de la persona o el cliente. Luego, al intentar guardar el objeto se genera un error colateral:
Dado que la factura carece de cliente, al preguntarle el nombre a este ùltimo explota.
Revisar las validaciones.