form_for はどんなものかをまとめてみた

自分の覚書です。

<%= form_for(@blog) do |f| %>
  <%= f.label :本文 %>
  <%= f.text_field :content %>
  <br>
  <%= f.submit '投稿'%>
<% end %>

というコードの場合、HTMLでは、

<label for="blog_本文">本文</label>
<input type="text" name="blog[content]" id="blog_content" />
<br>
<input type="submit" name="commit" value="投稿" />

となり、画面表示は

f:id:shounen070505:20170713171437p:plain

となる。