From 45072f34d27bda34b182f14f8b02d778d1648cce Mon Sep 17 00:00:00 2001
From: John Kelly Ferguson
+ <%= f.label :title %>
+ <%= f.label :text %>
+ <%= f.submit %>
+
+ Title:
+ <%= @article.title %>
+
+ Text:
+ <%= @article.text %>
+<%= pluralize(@article.errors.count, "error") %> prohibited
+ this article from being saved:
+
+ <% @article.errors.full_messages.each do |msg| %>
+
+
+ <%= f.text_field :title %>
+
+ <%= f.text_area :text %>
+ Edit article
+
+<%= render 'form' %>
+
+<%= link_to 'Back', action: :index %>
diff --git a/guides/code/getting_started/app/views/articles/index.html.erb b/guides/code/getting_started/app/views/articles/index.html.erb
new file mode 100644
index 0000000000..80e9c8c60c
--- /dev/null
+++ b/guides/code/getting_started/app/views/articles/index.html.erb
@@ -0,0 +1,21 @@
+Listing Articles
+
+
diff --git a/guides/code/getting_started/app/views/articles/new.html.erb b/guides/code/getting_started/app/views/articles/new.html.erb
new file mode 100644
index 0000000000..652b1c9c0b
--- /dev/null
+++ b/guides/code/getting_started/app/views/articles/new.html.erb
@@ -0,0 +1,5 @@
+
+
+
+<% @articles.each do |article| %>
+ Title
+ Text
+
+
+
+
+
+<% end %>
+<%= article.title %>
+ <%= article.text %>
+ <%= link_to 'Show', action: :show, id: article.id %>
+ <%= link_to 'Edit', action: :edit, id: article.id %>
+ <%= link_to 'Destroy', { action: :destroy, id: article.id },
+ method: :delete, data: { confirm: 'Are you sure?' } %>
+ New article
+
+<%= render 'form' %>
+
+<%= link_to 'Back', action: :index %>
diff --git a/guides/code/getting_started/app/views/articles/show.html.erb b/guides/code/getting_started/app/views/articles/show.html.erb
new file mode 100644
index 0000000000..6959c80bdb
--- /dev/null
+++ b/guides/code/getting_started/app/views/articles/show.html.erb
@@ -0,0 +1,18 @@
+Comments
+<%= render @article.comments %>
+
+Add a comment:
+<%= render "comments/form" %>
+
+<%= link_to 'Edit Article', edit_article_path(@article) %> |
+<%= link_to 'Back to Articles', articles_path %>
diff --git a/guides/code/getting_started/app/views/comments/_comment.html.erb b/guides/code/getting_started/app/views/comments/_comment.html.erb
index 593493339e..f7cbfaebfa 100644
--- a/guides/code/getting_started/app/views/comments/_comment.html.erb
+++ b/guides/code/getting_started/app/views/comments/_comment.html.erb
@@ -2,14 +2,14 @@
Commenter:
<%= comment.commenter %>
Comment: <%= comment.body %>
- <%= link_to 'Destroy Comment', [comment.post, comment], + <%= link_to 'Destroy Comment', [comment.article, comment], method: :delete, data: { confirm: 'Are you sure?' } %>
diff --git a/guides/code/getting_started/app/views/comments/_form.html.erb b/guides/code/getting_started/app/views/comments/_form.html.erb index 00cb3a08f0..5850c41a17 100644 --- a/guides/code/getting_started/app/views/comments/_form.html.erb +++ b/guides/code/getting_started/app/views/comments/_form.html.erb @@ -1,4 +1,4 @@ -<%= form_for([@post, @post.comments.build]) do |f| %> +<%= form_for([@article, @article.comments.build]) do |f| %>
<%= f.label :commenter %>
<%= f.text_field :commenter %>
diff --git a/guides/code/getting_started/app/views/posts/_form.html.erb b/guides/code/getting_started/app/views/posts/_form.html.erb
deleted file mode 100644
index f2f83585e1..0000000000
--- a/guides/code/getting_started/app/views/posts/_form.html.erb
+++ /dev/null
@@ -1,27 +0,0 @@
-<%= form_for @post do |f| %>
- <% if @post.errors.any? %>
-
- <%= f.label :title %>
- <%= f.text_field :title %>
-
- <%= f.label :text %>
- <%= f.text_area :text %>
-
- <%= f.submit %> -
-<% end %> - diff --git a/guides/code/getting_started/app/views/posts/edit.html.erb b/guides/code/getting_started/app/views/posts/edit.html.erb deleted file mode 100644 index 393e7430d0..0000000000 --- a/guides/code/getting_started/app/views/posts/edit.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -Title | -Text | -- | - | - |
---|---|---|---|---|
<%= post.title %> | -<%= post.text %> | -<%= link_to 'Show', action: :show, id: post.id %> | -<%= link_to 'Edit', action: :edit, id: post.id %> | -<%= link_to 'Destroy', { action: :destroy, id: post.id }, - method: :delete, data: { confirm: 'Are you sure?' } %> | -
- Title: - <%= @post.title %> -
- -- Text: - <%= @post.text %> -
- -