From f0de7172a6e1a52bf122578954d805a36a488d27 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Tue, 24 Apr 2012 14:21:07 +0200 Subject: Add update post section to getting started guide --- guides/code/getting_started/app/views/posts/_form.html.erb | 2 +- guides/code/getting_started/app/views/posts/edit.html.erb | 3 +-- guides/code/getting_started/app/views/posts/index.html.erb | 2 ++ guides/code/getting_started/app/views/posts/show.html.erb | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) (limited to 'guides/code/getting_started/app/views/posts') 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 18cb29f335..46ec257b91 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,4 @@ -<%= form_for :post, :url => { :action => :create } do |f| %> +<%= form_for :post, :url => { :action => :update, :id => @post.id }, :method => :put do |f| %> <% if @post.errors.any? %>

<%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:

diff --git a/guides/code/getting_started/app/views/posts/edit.html.erb b/guides/code/getting_started/app/views/posts/edit.html.erb index 720580236b..911a48569d 100644 --- a/guides/code/getting_started/app/views/posts/edit.html.erb +++ b/guides/code/getting_started/app/views/posts/edit.html.erb @@ -2,5 +2,4 @@ <%= render 'form' %> -<%= link_to 'Show', @post %> | -<%= link_to 'Back', posts_path %> +<%= link_to 'Back', :action => :index %> 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 455a74b17f..3ba7091c15 100644 --- a/guides/code/getting_started/app/views/posts/index.html.erb +++ b/guides/code/getting_started/app/views/posts/index.html.erb @@ -7,6 +7,7 @@ Title Text + <% @posts.each do |post| %> @@ -14,6 +15,7 @@ <%= post.title %> <%= post.text %> <%= link_to 'Show', :action => :show, :id => post.id %> + <%= link_to 'Edit', :action => :edit, :id => post.id %> <% end %> 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 a79fadfe4c..aea28cd5a2 100644 --- a/guides/code/getting_started/app/views/posts/show.html.erb +++ b/guides/code/getting_started/app/views/posts/show.html.erb @@ -9,3 +9,4 @@

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