From 06a1519a4dc714822bec2312a41950aedba82541 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Mon, 30 Apr 2012 09:08:32 +0200 Subject: Rewrite adding a second model section of Getting Started Guide --- .../getting_started/app/views/posts/_form.html.erb | 4 ++-- .../getting_started/app/views/posts/show.html.erb | 20 ++++++++++++++++++-- guides/code/getting_started/config/routes.rb | 4 +++- 3 files changed, 23 insertions(+), 5 deletions(-) (limited to 'guides/code/getting_started') 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 b35ea2f237..f22139938c 100644 --- a/guides/code/getting_started/app/views/posts/_form.html.erb +++ b/guides/code/getting_started/app/views/posts/_form.html.erb @@ -10,12 +10,12 @@ <% end %>

- <%= f.label :title %>
+ <%= f.label :title %>
<%= f.text_field :title %>

- <%= f.label :text %>
+ <%= f.label :text %>
<%= f.text_area :text %>

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 aea28cd5a2..0580879c1a 100644 --- a/guides/code/getting_started/app/views/posts/show.html.erb +++ b/guides/code/getting_started/app/views/posts/show.html.erb @@ -8,5 +8,21 @@ <%= @post.text %>

-<%= link_to 'Back', :action => :index %> -| <%= link_to 'Edit', :action => :edit, :id => @post.id %> + +

Add a comment:

+<%= form_for([@post, @post.comments.build]) do |f| %> +

+ <%= f.label :commenter %>
+ <%= f.text_field :commenter %> +

+

+ <%= f.label :body %>
+ <%= f.text_area :body %> +

+

+ <%= f.submit %> +

+<% end %> + +<%= link_to 'Edit Post', edit_post_path(@post) %> | +<%= link_to 'Back to Posts', posts_path %> diff --git a/guides/code/getting_started/config/routes.rb b/guides/code/getting_started/config/routes.rb index 5fb85de766..04a6bd374e 100644 --- a/guides/code/getting_started/config/routes.rb +++ b/guides/code/getting_started/config/routes.rb @@ -1,6 +1,8 @@ Blog::Application.routes.draw do - resources :posts + resources :posts do + resources :comments + end # The priority is based upon order of creation: # first created -> highest priority. -- cgit v1.2.3