Ruby on rails 在表单Rails 4上添加占位符

Ruby on rails 在表单Rails 4上添加占位符,ruby-on-rails,forms,Ruby On Rails,Forms,我需要在正在编写的表单上添加占位符。我尝试了以下方法和其他一些变体,但没有成功: <%= form_tag("/search", method: "get") do %> <%= label_tag(:address, "Address:", placeholder: '100 Brooklyn Ave Unit 3' ) %> <%= text_field_tag(:address) %> <%= label_tag(:city

我需要在正在编写的表单上添加占位符。我尝试了以下方法和其他一些变体,但没有成功:

<%= form_tag("/search", method: "get") do %>
    <%= label_tag(:address, "Address:", placeholder: '100 Brooklyn Ave Unit 3' ) %>
    <%= text_field_tag(:address) %>
    <%= label_tag(:citystatezip, "City and State OR ZIP:", placeholder: 'New York, NY') %>
    <%= text_field_tag(:citystatezip) %>
    <%= submit_tag("Enter Address") %>
  <% end %>

您不能将占位符放在标签标签中,它们应该放在输入字段中,在这种情况下:

<%= form_tag("/search", method: "get") do %>
  <%= label_tag(:address, "Address:") %>
  <%= text_field_tag(:address, nil, placeholder: '100 Brooklyn Ave Unit 3') %>
  <%= label_tag(:citystatezip, "City and State OR ZIP:") %>
  <%= text_field_tag(:citystatezip, nil, placeholder: 'New York, NY') %>
  <%= submit_tag("Enter Address") %>
<% end %>