diff options
Diffstat (limited to 'guides/code/getting_started')
-rw-r--r-- | guides/code/getting_started/app/controllers/posts_controller.rb | 1 | ||||
-rw-r--r-- | guides/code/getting_started/app/views/posts/_form.html.erb | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/guides/code/getting_started/app/controllers/posts_controller.rb b/guides/code/getting_started/app/controllers/posts_controller.rb index 2ad69a9bcf..947cd2a767 100644 --- a/guides/code/getting_started/app/controllers/posts_controller.rb +++ b/guides/code/getting_started/app/controllers/posts_controller.rb @@ -9,6 +9,7 @@ class PostsController < ApplicationController end def new + @post = Post.new end def create diff --git a/guides/code/getting_started/app/views/posts/_form.html.erb b/guides/code/getting_started/app/views/posts/_form.html.erb index 51fa3f4f12..18cb29f335 100644 --- a/guides/code/getting_started/app/views/posts/_form.html.erb +++ b/guides/code/getting_started/app/views/posts/_form.html.erb @@ -1,4 +1,14 @@ <%= form_for :post, :url => { :action => :create } do |f| %> + <% if @post.errors.any? %> + <div id="errorExplanation"> + <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2> + <ul> + <% @post.errors.full_messages.each do |msg| %> + <li><%= msg %></li> + <% end %> + </ul> + </div> + <% end %> <p> <%= f.label :title %><br> <%= f.text_field :title %> |