'How can display an asociated value on nested form rails?
I have 3 tables gas, pot and pot details I'm trying to display an asociated value
Tables:
gas: id name
1 gas1
2 gas2
3 gas3
pot: id name
1 pot1
pot_details
id pot_id gas_id name
1 1 1 abc
2 1 2 cde
I'm tring to display the gas name insted of gas_id on nested form
<% f.fields_for :pot_details do |pot_detail_form| %>
<%= pot_detail_form.text_field :gas_id %>
<%= pot_detail_form.text_field :name %>
<% end %>
I tried
<%= pot_detail_form.label :gas_id , value: @gas.pluck(:gas_id).join(' ,') %>
I'm trying to replace gas_id and display gas.name
I'm trying to show this result
<label> gas1</label>
<input>input 1 </input>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
