0

i'm trying to show a value from my model, when select box value changes. my code it's like this.

<%= f.label :nit , "Client Nit:" %>
  <%= f.collection_select(:nit, Client.all, :nit, :nit, :prompt => "Select a  NIT")%>

My Client model has a name and a Nit, i need to display the value according to my Nit Selection For example:

I have in my table:

NIT=>Name

12345678=>John Doe

987654321=>Bruce Wayne

327654=>Clark Kent

If i choose the first one in the select box, i need to display "John Doe".

I'm trying to do this but nothing works for me.

1 Answer 1

0

Try this

<%= f.collection_select(:nit, Client.all,:nit,:name,:prompt => "Select a NIT")%>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.