From f6d5036dd620da48624ce32494f63aa4221b05d5 Mon Sep 17 00:00:00 2001
From: Oscar Del Ben
Date: Fri, 20 Apr 2012 10:43:50 +0200
Subject: Adapt "Getting started guide" code sample
---
.../getting_started/app/views/posts/_form.html.erb | 45 +++++++---------------
.../getting_started/app/views/posts/new.html.erb | 2 +-
2 files changed, 15 insertions(+), 32 deletions(-)
(limited to 'guides/code/getting_started/app/views')
diff --git a/guides/code/getting_started/app/views/posts/_form.html.erb b/guides/code/getting_started/app/views/posts/_form.html.erb
index e27da7f413..51fa3f4f12 100644
--- a/guides/code/getting_started/app/views/posts/_form.html.erb
+++ b/guides/code/getting_started/app/views/posts/_form.html.erb
@@ -1,32 +1,15 @@
-<% @post.tags.build %>
-<%= form_for(@post) do |post_form| %>
- <% if @post.errors.any? %>
-
-
<%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:
-
- <% @post.errors.full_messages.each do |msg| %>
- - <%= msg %>
- <% end %>
-
-
- <% end %>
-
-
- <%= post_form.label :name %>
- <%= post_form.text_field :name %>
-
-
- <%= post_form.label :title %>
- <%= post_form.text_field :title %>
-
-
- <%= post_form.label :content %>
- <%= post_form.text_area :content %>
-
- Tags
- <%= render :partial => 'tags/form',
- :locals => {:form => post_form} %>
-
- <%= post_form.submit %>
-
+<%= form_for :post, :url => { :action => :create } do |f| %>
+
+ <%= 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/new.html.erb b/guides/code/getting_started/app/views/posts/new.html.erb
index 36ad7421f9..5d6482f880 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', posts_path %>
--
cgit v1.2.3
From dbb4c4ddb601e06fef37f63d644a5297f3292c2a Mon Sep 17 00:00:00 2001
From: Oscar Del Ben
Date: Fri, 20 Apr 2012 10:47:38 +0200
Subject: New Getting started guide wont have tags
---
guides/code/getting_started/app/views/posts/show.html.erb | 7 +------
guides/code/getting_started/app/views/tags/_form.html.erb | 12 ------------
2 files changed, 1 insertion(+), 18 deletions(-)
delete mode 100644 guides/code/getting_started/app/views/tags/_form.html.erb
(limited to 'guides/code/getting_started/app/views')
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 da78a9527b..3445fd8779 100644
--- a/guides/code/getting_started/app/views/posts/show.html.erb
+++ b/guides/code/getting_started/app/views/posts/show.html.erb
@@ -14,12 +14,7 @@
Content:
<%= @post.content %>
-
-
- Tags:
- <%= join_tags(@post) %>
-
-
+
Comments
<%= render @post.comments %>
diff --git a/guides/code/getting_started/app/views/tags/_form.html.erb b/guides/code/getting_started/app/views/tags/_form.html.erb
deleted file mode 100644
index 7e424b0e20..0000000000
--- a/guides/code/getting_started/app/views/tags/_form.html.erb
+++ /dev/null
@@ -1,12 +0,0 @@
-<%= form.fields_for :tags do |tag_form| %>
-
- <%= tag_form.label :name, 'Tag:' %>
- <%= tag_form.text_field :name %>
-
- <% unless tag_form.object.nil? || tag_form.object.new_record? %>
-
- <%= tag_form.label :_destroy, 'Remove:' %>
- <%= tag_form.check_box :_destroy %>
-
- <% end %>
-<% end %>
--
cgit v1.2.3
From 2e2afc0ac64190261df4b05428afddea96c8628c Mon Sep 17 00:00:00 2001
From: Oscar Del Ben
Date: Fri, 20 Apr 2012 12:06:47 +0200
Subject: Add show action in getting started guide
---
.../getting_started/app/views/posts/show.html.erb | 25 ++++------------------
1 file changed, 4 insertions(+), 21 deletions(-)
(limited to 'guides/code/getting_started/app/views')
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 3445fd8779..6207babdf0 100644
--- a/guides/code/getting_started/app/views/posts/show.html.erb
+++ b/guides/code/getting_started/app/views/posts/show.html.erb
@@ -1,26 +1,9 @@
-<%= notice %>
-
- Name:
- <%= @post.name %>
-
-
-
- Title:
+ Title:
<%= @post.title %>
-
+
- Content:
- <%= @post.content %>
+ Text:
+ <%= @post.text %>
-
-Comments
-<%= render @post.comments %>
-
-Add a comment:
-<%= render "comments/form" %>
-
-
-<%= link_to 'Edit Post', edit_post_path(@post) %> |
-<%= link_to 'Back to Posts', posts_path %> |
--
cgit v1.2.3
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
---
.../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 ++
5 files changed, 10 insertions(+), 16 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/views')
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
From 3da2b530aff28d4ea0272e36578188bb6869cbcc Mon Sep 17 00:00:00 2001
From: Oscar Del Ben
Date: Sat, 21 Apr 2012 12:17:51 +0200
Subject: Add validation code to getting started guide and improve validation
section
---
guides/code/getting_started/app/views/posts/_form.html.erb | 10 ++++++++++
1 file changed, 10 insertions(+)
(limited to 'guides/code/getting_started/app/views')
diff --git a/guides/code/getting_started/app/views/posts/_form.html.erb b/guides/code/getting_started/app/views/posts/_form.html.erb
index 51fa3f4f12..18cb29f335 100644
--- a/guides/code/getting_started/app/views/posts/_form.html.erb
+++ b/guides/code/getting_started/app/views/posts/_form.html.erb
@@ -1,4 +1,14 @@
<%= form_for :post, :url => { :action => :create } do |f| %>
+ <% if @post.errors.any? %>
+
+
<%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:
+
+ <% @post.errors.full_messages.each do |msg| %>
+ - <%= msg %>
+ <% end %>
+
+
+ <% end %>
<%= f.label :title %>
<%= f.text_field :title %>
--
cgit v1.2.3