これまでに作った機能について簡単にまとめていく。
今回は、
パーシャルの作成
ファイルの作成
app/views/blogs/_form.html.erb
パーシャルを識別するために_から始まるファイル名を作成する
今回はフォームを作成
1 2 3 4 5 6 7 8 9 10 |
<%= form_with(model: @blog, local: true) do |form| %> %> <%= form.label :title %> <%= form.text_field :title %> <%= form.label :content %> <%= form.text_field :content %> <%= form.submit %> <% end %> |
パーシャルの呼び出し
app/views/blogs/new.html.erb
1 |
<%= render 'form' %> |
以上で作成完了