Browse files

[getting started] split up addition of links to index/show/new area

  • Loading branch information...
1 parent 95e14d1 commit aa7f2a3564aeae17adfbf0c8f40fe38b072c7d52 @radar radar committed May 16, 2012
Showing with 7 additions and 23 deletions.
  1. +7 −23 guides/source/getting_started.textile
30 guides/source/getting_started.textile
@@ -612,41 +612,25 @@ The +link_to+ method is one of Rails' built-in view helpers. It creates a
hyperlink based on text to display and where to go - in this case, to the path
for posts.
-Let's add links to the other views as well.
+Let's add links to the other views as well, starting with adding this "New Post" link to +app/views/posts/index.html.erb+, placing it above the +<table>+ tag:
-# app/views/posts/index.html.erb
-<h1>Listing posts</h1>
<%= link_to 'New post', :action => :new %>
- <tr>
- <th>Title</th>
- <th>Text</th>
- <th></th>
- </tr>
-<% @posts.each do |post| %>
- <tr>
- <td><%= post.title %></td>
- <td><%= post.text %></td>
- <td><%= link_to 'Show', :action => :show, :id => %></td>
- </tr>
-<% end %>
-# app/views/posts/new.html.erb
+This link will allow you to bring up the form that lets you create a new post. You should also add a link to this template -- +app/views/posts/new.html.erb+ -- to go back to the +index+ action. Do this by adding this underneath the form in this template:
<%= form_for :post do |f| %>
<% end %>
<%= link_to 'Back', :action => :index %>
-# app/views/posts/show.html.erb
+Finally, add another link to the +app/views/posts/show.html.erb+ template to go back to the +index+ action as well, so that people who are viewing a single post can go back and view the whole list again:
<%= @post.title %>

0 comments on commit aa7f2a3

Please sign in to comment.