Id of the first table does not load in the DB

4

I'm trying to create a simple contact directory with two tables: Being one of them empresa :nome and the other contatos :nome :telefone :email ... I created the two tables and placed a Foreign_key in the second one that will receive the first_ company. p>

In the form of the second table I put a f.collection_select of the following%: <%= f.collection_select :empresa,Empresa.order('nome Asc'),:id, :nome,{prompt: "Selecione uma empresa"},{class: "form-control"} %> . It works only that when I select the company and include the other fields the company id does not save in the Bank. Could you help me by telling me where I'm going wrong?

    
asked by anonymous 08.08.2014 / 20:24

1 answer

3

I was able to resolve it as follows:

<%= f.collection_select(:empresa_id, Empresa.all.order(:nome), :id, :nome {prompt :true}) %>

And so it worked!

    
12.08.2014 / 00:48