Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[getting started] Split up creation of route, action and view for Pos…

…tsController#index
  • Loading branch information...
commit 533bcd75d392cd1e0a9fcc5976237e877953477d 1 parent 0666e7b
@radar radar authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 guides/source/getting_started.textile
View
10 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+:
<ruby>
-# Add to config/routes.rb
get "posts" => "posts#index"
+</ruby>
+
+And an action for that route inside the +PostsController+ in the +app/controllers/posts_controller.rb+ file:
-# Add to app/controllers/posts_controller.rb
+<ruby>
def index
@posts = Post.all
end
</ruby>
-+app/view/posts/index.html.erb+:
+And then finally a view for this action, located at +app/views/posts/index.html.erb+:
<erb>
<h1>Listing posts</h1>
Please sign in to comment.
Something went wrong with that request. Please try again.