diff options
author | Ryan Bigg <radarlistener@gmail.com> | 2012-05-16 17:47:21 +1000 |
---|---|---|
committer | Ryan Bigg <radarlistener@gmail.com> | 2012-05-16 18:05:35 +1000 |
commit | aa7f2a3564aeae17adfbf0c8f40fe38b072c7d52 (patch) | |
tree | 09179ee016fe1df06b43dfa2fbc277fe95fd5089 /guides/source | |
parent | 95e14d1523ae075a39ce6c6efe68b13db43a16d8 (diff) | |
download | rails-aa7f2a3564aeae17adfbf0c8f40fe38b072c7d52.tar.gz rails-aa7f2a3564aeae17adfbf0c8f40fe38b072c7d52.tar.bz2 rails-aa7f2a3564aeae17adfbf0c8f40fe38b072c7d52.zip |
[getting started] split up addition of links to index/show/new area
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/getting_started.textile | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index 9870b157d8..d718ba409a 100644 --- a/guides/source/getting_started.textile +++ b/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: <erb> -# app/views/posts/index.html.erb - -<h1>Listing posts</h1> - <%= link_to 'New post', :action => :new %> +</erb> -<table> - <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 => post.id %></td> - </tr> -<% end %> -</table> - -# 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: +<erb> <%= form_for :post do |f| %> ... <% end %> <%= link_to 'Back', :action => :index %> +</erb> -# 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: +<erb> <p> <strong>Title:</strong> <%= @post.title %> |