Skip to content

Commit

Permalink
Add fields and submit button to form template
Browse files Browse the repository at this point in the history
This is another case where all we needed to add to get the test to pass was the title field. But this is a reasonable case where you know what the form will consist of, so you can go ahead and create it all. Plus, your tests will never drive out the full markup of your templates, so you'll need to do that by hand anyway.

Red: First argument in form cannot contain nil or be empty

<%= form_for @blog_post do |f| %>

In other words, @blog_post is nil but needs to be a model.
  • Loading branch information
Josh Justice committed Apr 9, 2018
1 parent 48b6da6 commit 7144bb1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/views/blog_posts/new.html.erb
@@ -1 +1,11 @@
<%# empty view %> <%= form_for @blog_post do |f| %>
<div>
<%= f.label :title %>
<%= f.text_field :title %>
</div>
<div>
<%= f.label :body %>
<%= f.text_area :body %>
</div>
<%= f.submit 'Create Blog Post' %>
<% end %>

0 comments on commit 7144bb1

Please sign in to comment.