From 943410197cca4235212ca0fc409820378a40890c Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Sat, 28 Apr 2012 11:44:50 +0200 Subject: Add REST section to getting started guide --- guides/code/getting_started/config/routes.rb | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'guides/code') diff --git a/guides/code/getting_started/config/routes.rb b/guides/code/getting_started/config/routes.rb index 6095a05a58..5fb85de766 100644 --- a/guides/code/getting_started/config/routes.rb +++ b/guides/code/getting_started/config/routes.rb @@ -1,15 +1,6 @@ Blog::Application.routes.draw do - # resources :posts do - # resources :comments - # end - get "posts" => "posts#index" - get "posts/new" - post "posts/create" - get "posts/:id" => "posts#show", :as => :post - get "posts/:id/edit" => "posts#edit" - put "posts/:id" => "posts#update" - delete "posts/:id" => "posts#destroy" + resources :posts # The priority is based upon order of creation: # first created -> highest priority. -- cgit v1.2.3 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') 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 From 2a15598ae859d7ca62755f15bc2efd5036f6bc52 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Tue, 1 May 2012 10:58:16 +0200 Subject: Getting Started Guide Code Cleanup --- guides/code/getting_started/test/fixtures/tags.yml | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 guides/code/getting_started/test/fixtures/tags.yml (limited to 'guides/code') diff --git a/guides/code/getting_started/test/fixtures/tags.yml b/guides/code/getting_started/test/fixtures/tags.yml deleted file mode 100644 index 8485668908..0000000000 --- a/guides/code/getting_started/test/fixtures/tags.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html - -one: - name: MyString - post: - -two: - name: MyString - post: -- cgit v1.2.3