samedi 15 octobre 2016

Get and display all values from database row separately based on select (Rails)

Hi i'm stuck making an invoicing application and i want to have an option where you can add an existing user from the customers table and add those values to the invoice.

The values i want to display are company_name, vat_number and iban_number.

I tried doing this:

<%= select_tag 'choose customer', options_from_collection_for_select(current_user.companies.all, 'id', 'company_name') %>

But obviously this only gets the value of company_name.

I tried using collection.select but that one also gets only one value of the database row instead of all 3.

I want to be able to select from a list or table row containing just the company_name but when i click on that company_name it has to also display vat_number and iban_number.

Any ideas on how to achieve this or where to look for the answer would be much much appreciated

Aucun commentaire:

Enregistrer un commentaire