Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Invoice.rb:
- has_many :service_types, through: :invoice_service_type,
- Invoice form:
- <div class="col-md-12" id="ServiceType">
- <strong>Serviços:</strong>
- <%= f.simple_fields_for :invoice_service_types do |invoice_service_type| %><br>
- <%= render 'invoices/invoice_service_type_fields', f: invoice_service_type %>
- <% end %>
- </div>
- <br/><br/><%= link_to_add_association ' Novo Serviço', f, :invoice_service_types, class: 'fa fa-plus btn btn-success' %>
- </div>
- Invoice Service Types, with fix name of service types, but different values for each Service Type and Invoice.
- invoice_service_type_fields form:
- <div class="nested-fields form-inline">
- <div class="col-xs-12 col-lg-12">
- <%= f.association :service_type, collection: ServiceType.all.each.map {|v, k|[v.name, v.id]}, prompt: 'Escolha o Serviço', label: false %>
- <%= f.input :value_charged, class: "form-control", placeholder: "Valor cobrado", label: false %>
- <%= link_to_remove_association "", f, class:"fa fa-trash-o h3", style:'font-size: 20px;' %>
- </div>
- </div>
- InvoiceServiceType.rb
- belongs_to :invoice
- belongs_to :service_type
- Schema for InvoiceServiceType: ( this what take me a lot of time, to discover how to have diferent values for same kind os service type )
- create_table "invoice_service_types", force: :cascade do |t|
- t.float "value_charged"
- t.integer "invoice_id"
- t.integer "service_type_id"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement