From 533bcd75d392cd1e0a9fcc5976237e877953477d Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Wed, 16 May 2012 10:50:57 +1000 Subject: [getting started] Split up creation of route, action and view for PostsController#index --- guides/source/getting_started.textile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index e93a94448a..f449cc9679 100644 --- a/guides/source/getting_started.textile +++ b/guides/source/getting_started.textile @@ -560,19 +560,21 @@ be able to create a post. Try it! h4. Listing all posts We still need a way to list all our posts, so let's do that. As usual, -we'll need a route, a controller action, and a view: +we'll need a route placed into +config/routes.rb+: -# Add to config/routes.rb get "posts" => "posts#index" + + +And an action for that route inside the +PostsController+ in the +app/controllers/posts_controller.rb+ file: -# Add to app/controllers/posts_controller.rb + def index @posts = Post.all end -+app/view/posts/index.html.erb+: +And then finally a view for this action, located at +app/views/posts/index.html.erb+:

Listing posts

-- cgit v1.2.3