使用 Ruby on Rails 3.2。我正在尝试基于定义的数组创建多个隐藏字段标记。下面是我的代码:
# shop.rb
...
ADDRESS_COMPONENTS = ['lat', 'lng', 'name']
...
# shops_helper.rb
module ShopsHelper
def address_components_hidden_fields
Shop::ADDRESS_COMPONENTS.each do |address_component|
hidden_field_tag(address_component, "")
end
end
end
# _form.html.erb
<%= address_components_hidden_fields %>
输出是:
['lat', 'lng', 'name']
我期望输出是:
<input type='hidden' name='lat' id='lat' value='' />
<input type='hidden' name='lng' id='lng' value='' />
<input type='hidden' name='name' id='name' value='' />
我做错了什么?