From e7e72aa253d9cb3bef786a955794986d1f3ff871 Mon Sep 17 00:00:00 2001
From: Oscar Del Ben
Date: Fri, 20 Apr 2012 12:53:18 +0200
Subject: Add index and links section to Getting started guide
---
.../getting_started/app/controllers/home_controller.rb | 2 +-
.../app/controllers/posts_controller.rb | 3 +++
guides/code/getting_started/app/helpers/home_helper.rb | 2 +-
.../code/getting_started/app/views/home/index.html.erb | 2 --
.../getting_started/app/views/posts/index.html.erb | 18 +++++-------------
.../code/getting_started/app/views/posts/new.html.erb | 2 +-
.../code/getting_started/app/views/posts/show.html.erb | 2 ++
.../getting_started/app/views/welcome/index.html.erb | 2 ++
8 files changed, 15 insertions(+), 18 deletions(-)
delete mode 100644 guides/code/getting_started/app/views/home/index.html.erb
create mode 100644 guides/code/getting_started/app/views/welcome/index.html.erb
(limited to 'guides/code/getting_started/app')
diff --git a/guides/code/getting_started/app/controllers/home_controller.rb b/guides/code/getting_started/app/controllers/home_controller.rb
index 6cc31c1ca3..309b70441e 100644
--- a/guides/code/getting_started/app/controllers/home_controller.rb
+++ b/guides/code/getting_started/app/controllers/home_controller.rb
@@ -1,4 +1,4 @@
-class HomeController < ApplicationController
+class WelcomeController < ApplicationController
def index
end
diff --git a/guides/code/getting_started/app/controllers/posts_controller.rb b/guides/code/getting_started/app/controllers/posts_controller.rb
index f9181f98c6..e4d83dd279 100644
--- a/guides/code/getting_started/app/controllers/posts_controller.rb
+++ b/guides/code/getting_started/app/controllers/posts_controller.rb
@@ -1,5 +1,8 @@
class PostsController < ApplicationController
+ def index
+ @posts = Post.all
+ end
def show
@post = Post.find(params[:id])
diff --git a/guides/code/getting_started/app/helpers/home_helper.rb b/guides/code/getting_started/app/helpers/home_helper.rb
index 23de56ac60..eeead45fc9 100644
--- a/guides/code/getting_started/app/helpers/home_helper.rb
+++ b/guides/code/getting_started/app/helpers/home_helper.rb
@@ -1,2 +1,2 @@
-module HomeHelper
+module WelcomeHelper
end
diff --git a/guides/code/getting_started/app/views/home/index.html.erb b/guides/code/getting_started/app/views/home/index.html.erb
deleted file mode 100644
index bb4f3dcd1f..0000000000
--- a/guides/code/getting_started/app/views/home/index.html.erb
+++ /dev/null
@@ -1,2 +0,0 @@
-Hello, Rails!
-<%= link_to "My Blog", posts_path %>
diff --git a/guides/code/getting_started/app/views/posts/index.html.erb b/guides/code/getting_started/app/views/posts/index.html.erb
index 45dee1b25f..455a74b17f 100644
--- a/guides/code/getting_started/app/views/posts/index.html.erb
+++ b/guides/code/getting_started/app/views/posts/index.html.erb
@@ -1,27 +1,19 @@
Listing posts
+<%= link_to 'New post', :action => :new %>
+
- Name |
Title |
- Content |
- |
- |
+ Text |
|
<% @posts.each do |post| %>
- <%= post.name %> |
<%= post.title %> |
- <%= post.content %> |
- <%= link_to 'Show', post %> |
- <%= link_to 'Edit', edit_post_path(post) %> |
- <%= link_to 'Destroy', post, confirm: 'Are you sure?', method: :delete %> |
+ <%= post.text %> |
+ <%= link_to 'Show', :action => :show, :id => post.id %>
|
<% end %>
-
-
-
-<%= link_to 'New Post', new_post_path %>
diff --git a/guides/code/getting_started/app/views/posts/new.html.erb b/guides/code/getting_started/app/views/posts/new.html.erb
index 5d6482f880..ce9523a721 100644
--- a/guides/code/getting_started/app/views/posts/new.html.erb
+++ b/guides/code/getting_started/app/views/posts/new.html.erb
@@ -2,4 +2,4 @@
<%= render 'form' %>
-<%#= link_to 'Back', posts_path %>
+<%= link_to 'Back', :action => :index %>
diff --git a/guides/code/getting_started/app/views/posts/show.html.erb b/guides/code/getting_started/app/views/posts/show.html.erb
index 6207babdf0..a79fadfe4c 100644
--- a/guides/code/getting_started/app/views/posts/show.html.erb
+++ b/guides/code/getting_started/app/views/posts/show.html.erb
@@ -7,3 +7,5 @@
Text:
<%= @post.text %>
+
+<%= link_to 'Back', :action => :index %>
diff --git a/guides/code/getting_started/app/views/welcome/index.html.erb b/guides/code/getting_started/app/views/welcome/index.html.erb
new file mode 100644
index 0000000000..e04680ea7e
--- /dev/null
+++ b/guides/code/getting_started/app/views/welcome/index.html.erb
@@ -0,0 +1,2 @@
+Hello, Rails!
+<%= link_to "My Blog", :controller => "posts" %>
--
cgit v1.2.3