在文本字段上设置值

时间:2012-08-02 13:30:18

标签: ruby-on-rails ruby

在我的应用程序中,我想将值设置为textfield。我想像这里一样做

<input type="text" value ="something">

我的问题怎么能在rails视图上做同样的事情。

   <h1>New location</h1>

<% form_for(@location) do |f| %>
  <%=  f.error_messages %>

  <p>
    <%= f.label :address %><br />
    <%=  f.text_field :address %>

  </p>
  <p>
    <%= f.label :latitude %><br />
    <%= f.text_field :latitude %>
  </p>
  <p>
    <%= f.label :longitude %><br />
    <%= f.text_field :longitude %>
  </p>
  <p>
    <%= f.submit 'Create' %>
  </p>
<% end %>

<%= link_to 'Back', locations_path %>

1 个答案:

答案 0 :(得分:4)

传递value参数

<%= f.text_field :latitude, :value => 17 %>
相关问题