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 --- .../app/controllers/posts_controller.rb | 7 +++++- guides/code/getting_started/app/models/post.rb | 3 --- .../getting_started/app/views/posts/show.html.erb | 25 ++++------------------ 3 files changed, 10 insertions(+), 25 deletions(-) (limited to 'guides/code/getting_started/app') diff --git a/guides/code/getting_started/app/controllers/posts_controller.rb b/guides/code/getting_started/app/controllers/posts_controller.rb index 3373443b16..f9181f98c6 100644 --- a/guides/code/getting_started/app/controllers/posts_controller.rb +++ b/guides/code/getting_started/app/controllers/posts_controller.rb @@ -1,5 +1,10 @@ class PostsController < ApplicationController + + def show + @post = Post.find(params[:id]) + end + def new end @@ -7,6 +12,6 @@ class PostsController < ApplicationController @post = Post.new(params[:post]) @post.save - redirect_to :action => :index + redirect_to :action => :show, :id => @post.id end end diff --git a/guides/code/getting_started/app/models/post.rb b/guides/code/getting_started/app/models/post.rb index e77e607f3f..21387340b0 100644 --- a/guides/code/getting_started/app/models/post.rb +++ b/guides/code/getting_started/app/models/post.rb @@ -3,7 +3,4 @@ class Post < ActiveRecord::Base :length => { :minimum => 5 } has_many :comments, :dependent => :destroy - - accepts_nested_attributes_for :tags, :allow_destroy => :true, - :reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? } } 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 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