I have a partial like:
<% office.map do |o| %>
<input id='city' name='company[company_office][0][city]' value=.... type='text' />
<% end %>
How can I insert a value like o.office into an attribute? value="#{o.office}" does not work.
<% office.map do |o| %>
<input id='city' name='company[company_office][0][city]' value='<%= o.office %>' type='text' />
<% end %>
or you could use the form helpers for that
Use embedded ruby(erb) tags,
<%= o.office %>
The only time you'd use #{o.office} is when you're not using erb. In a helper method for example and you want to use your ruby in a string. But when you're in an html.erb file, you have to use the erb tags.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With