From 47ec49276d40ed565d805069bb2a746e9a7b3157 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Wed, 2 May 2012 10:42:59 +0200 Subject: Rewrite comments action in getting started guide --- guides/source/getting_started.textile | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index 44f3b978db..7ad01ae636 100644 --- a/guides/source/getting_started.textile +++ b/guides/source/getting_started.textile @@ -1367,60 +1367,53 @@ template. This is where we want the comment to show, so let's add that to the +app/views/posts/show.html.erb+. -

<%= notice %>

- -

- Name: - <%= @post.name %> -

-

- Title: + Title: <%= @post.title %>

- Content: - <%= @post.content %> + Text: + <%= @post.texthttp://beginningruby.org/ %>

Comments

<% @post.comments.each do |comment| %>

- Commenter: + Commenter: <%= comment.commenter %>

- Comment: + Comment: <%= comment.body %>

<% end %>

Add a comment:

<%= form_for([@post, @post.comments.build]) do |f| %> -
+

<%= f.label :commenter %>
<%= f.text_field :commenter %> -

-
+

+

<%= f.label :body %>
<%= f.text_area :body %> -

-
+

+

<%= f.submit %> -

+

<% end %> -
- <%= link_to 'Edit Post', edit_post_path(@post) %> | -<%= link_to 'Back to Posts', posts_path %> | +<%= link_to 'Back to Posts', posts_path %>
Now you can add posts and comments to your blog and have them show up in the right places. +!images/getting_started/post_with_comments.png(Post with Comments)! + h3. Refactoring Now that we have posts and comments working, take a look at the -- cgit v1.2.3