diff options
author | Ryan Bigg <radarlistener@gmail.com> | 2012-05-16 10:50:57 +1000 |
---|---|---|
committer | Ryan Bigg <radarlistener@gmail.com> | 2012-05-16 10:51:44 +1000 |
commit | 533bcd75d392cd1e0a9fcc5976237e877953477d (patch) | |
tree | c68a1269e86ac85be8efc7181754bbbf3cf96a0e /guides/source | |
parent | 0666e7b3bf70e4dc80ba9499812170fb39cd02a2 (diff) | |
download | rails-533bcd75d392cd1e0a9fcc5976237e877953477d.tar.gz rails-533bcd75d392cd1e0a9fcc5976237e877953477d.tar.bz2 rails-533bcd75d392cd1e0a9fcc5976237e877953477d.zip |
[getting started] Split up creation of route, action and view for PostsController#index
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/getting_started.textile | 10 |
1 files changed, 6 insertions, 4 deletions
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+: <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> |