vendredi 14 avril 2017

Rails f.select Save Id an Name at the same time

I have a form with selection options. I want to add the ID and the Company Name when the company name is selected from the options. Is it possible to add multiple attributes in the f.select line of code? This is how my code looks:

<div class="field">
 <%= f.label 'Client' %>
 <%= f.select :client_id, Client.all.collect { |c| [ c.companyName, c.id ] } %>

I want to also assign the companyName to my :companyName attribute, but the id is the only thing that is being saved right now.

Thanks.

Aucun commentaire:

Enregistrer un commentaire