Show a selectbox with all registers that employee using or no associations

33 views Asked by At

So, I have a model Refinancing belongs to employee and employee has many refinancings. This employee can have many register (but register is just a column). In view refinancing, how make for show a selectbox with all registers? I tried

<%= f.association :register %>

but don't work. I need show all register that employee. What I do?

1

There are 1 answers

1
Bharat soni On BEST ANSWER

Hey you are using the wrong syntax, The simple_form have lots helper methods to populate the inputs...

f.association :company, label_method: :company_name, value_method: :id, include_blank: false

In the above code :company means, the association name not the column name, In list box we need to show a label and set the vale for submit.

The above syntax is pretty much clear that show the association and then label and value methods.

Hope that will clarify you. For more details please read the GitHub documents for the same.