<% @pid = item.producto_id %>
<br/>
Producto: <%= Producto.find_by_id(@pid) %><br/>
Costo de Compra: <%= @costo_de_compra = Producto.find(:all, :conditions => "id = #{@pid} ").*.costo_de_compra %><br/>
Precio de venta: <%= @precio_de_venta = item.precio_de_venta %><br/>
Utilidad de este producto: <%= @precio_de_venta - @costo_de_compra %><br/><br/>
<% end %>
and in my controller i have=
@ventas_ocurridas_en_este_periodo = Venta.find(:all, :conditions => [ created_at >= ? and created_at <= ? , Date.today.beginning_of_month, Date.tomorrow])
As i am looping and getting values from the items that aren t available originally how can i sum all the values that come off from this loop into a concentred total?
also i can t make the operation of @precio_de_venta - @costo_de_compra... something about arrays.