Multiply one field and add it to another Ruby on rails

0

I have a form which has a total_balance which shows the number of points I am getting at the time of loading the quantity "quantity" (kg, mtrs, liters, unit, etc.). To this the material is multiplied with a corresponding value Aluminum-kg-500pts .. the operation would be 50kg of aluminum * the 500pts that is worth according to my other table.

loading form:

<%= simple_form_for(@point) do |f| %>
  <%= f.error_notification %>
  <%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

  <div class="form-inputs">
    <%= f.input :total_balance %> <----- # aca se cargaria el total de todo
    <%= f.input :quantity %>
    <%= f.input :type_point %>
    <%= f.association :material, label_method: :name, value_method: :id %>
  </div>

  <div class="form-actions">
    <%= f.button :submit %>
  </div>
<% end %>

Material model:

class Material < ApplicationRecord
    belongs_to :type_material
    belongs_to :unit_of_measurement
    def name
        "#{type_material.name}- #{unit_of_measurement.name}- #{value}pts"       
    end
end

Point model:

class Point < ApplicationRecord
    belongs_to :material
end
    
asked by MarceloT 02.12.2018 в 09:43
source

0 answers