This is from an inherited codebase (I didn’t write this):
<% purchase_order.line_items.each do |line_item| %> <% location_product = line_item.location_product product = location_product.product par_min = location_product.par_min || 0 par_max = location_product.par_max || 0 on_hand = location_product.on_hand || 0 on_request = location_product.on_request || 0 on_order = product.on_order default_vendor_sku = line_item.product.prices.where(vendor_id: purchase_order.vendor.id).first&.vendor_sku rescue nil %>
This doesn’t seem very MVC, since variables are generally initialized in the controller, from how I understand MVC.
It looks like the person who wrote this wanted to create shorter variables based on the records being iterated through.
Is there a more Rails way to do this?