diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2012-05-04 17:51:15 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2012-05-04 17:51:15 +0530 |
commit | 3d9673d8f6fdb5e330b2a276df288834058a5260 (patch) | |
tree | fba92ce97bba236916bab79489eb68c8788390c9 /guides/code | |
parent | b24f1ce13884a86d6d93d0b16e1fc3716360b65a (diff) | |
parent | 616de66c55b58479e7da4271a0c990529395440e (diff) | |
download | rails-3d9673d8f6fdb5e330b2a276df288834058a5260.tar.gz rails-3d9673d8f6fdb5e330b2a276df288834058a5260.tar.bz2 rails-3d9673d8f6fdb5e330b2a276df288834058a5260.zip |
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'guides/code')
5 files changed, 18 insertions, 25 deletions
diff --git a/guides/code/getting_started/app/controllers/comments_controller.rb b/guides/code/getting_started/app/controllers/comments_controller.rb index 7447fd078b..cf3d1be42e 100644 --- a/guides/code/getting_started/app/controllers/comments_controller.rb +++ b/guides/code/getting_started/app/controllers/comments_controller.rb @@ -1,16 +1,17 @@ class CommentsController < ApplicationController http_basic_authenticate_with :name => "dhh", :password => "secret", :only => :destroy + def create @post = Post.find(params[:post_id]) @comment = @post.comments.create(params[:comment]) redirect_to post_path(@post) end - + def destroy @post = Post.find(params[:post_id]) @comment = @post.comments.find(params[:id]) @comment.destroy redirect_to post_path(@post) end - + end diff --git a/guides/code/getting_started/app/controllers/posts_controller.rb b/guides/code/getting_started/app/controllers/posts_controller.rb index 85d2c1de47..a8ac9aba5a 100644 --- a/guides/code/getting_started/app/controllers/posts_controller.rb +++ b/guides/code/getting_started/app/controllers/posts_controller.rb @@ -1,5 +1,7 @@ class PostsController < ApplicationController + http_basic_authenticate_with :name => "dhh", :password => "secret", :except => [:index, :show] + def index @posts = Post.all end diff --git a/guides/code/getting_started/app/views/comments/_comment.html.erb b/guides/code/getting_started/app/views/comments/_comment.html.erb index 4c3fbf26cd..0cebe0bd96 100644 --- a/guides/code/getting_started/app/views/comments/_comment.html.erb +++ b/guides/code/getting_started/app/views/comments/_comment.html.erb @@ -1,13 +1,13 @@ <p> - <b>Commenter:</b> + <strong>Commenter:</strong> <%= comment.commenter %> </p> - + <p> - <b>Comment:</b> + <strong>Comment:</strong> <%= comment.body %> </p> - + <p> <%= link_to 'Destroy Comment', [comment.post, comment], :confirm => 'Are you sure?', diff --git a/guides/code/getting_started/app/views/comments/_form.html.erb b/guides/code/getting_started/app/views/comments/_form.html.erb index d15bdd6b59..00cb3a08f0 100644 --- a/guides/code/getting_started/app/views/comments/_form.html.erb +++ b/guides/code/getting_started/app/views/comments/_form.html.erb @@ -1,13 +1,13 @@ <%= form_for([@post, @post.comments.build]) do |f| %> - <div class="field"> + <p> <%= f.label :commenter %><br /> <%= f.text_field :commenter %> - </div> - <div class="field"> + </p> + <p> <%= f.label :body %><br /> <%= f.text_area :body %> - </div> - <div class="actions"> + </p> + <p> <%= f.submit %> - </div> + </p> <% 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 0580879c1a..65809033ed 100644 --- a/guides/code/getting_started/app/views/posts/show.html.erb +++ b/guides/code/getting_started/app/views/posts/show.html.erb @@ -8,21 +8,11 @@ <%= @post.text %> </p> +<h2>Comments</h2> +<%= render @post.comments %> <h2>Add a comment:</h2> -<%= form_for([@post, @post.comments.build]) do |f| %> - <p> - <%= f.label :commenter %><br /> - <%= f.text_field :commenter %> - </p> - <p> - <%= f.label :body %><br /> - <%= f.text_area :body %> - </p> - <p> - <%= f.submit %> - </p> -<% end %> +<%= render "comments/form" %> <%= link_to 'Edit Post', edit_post_path(@post) %> | <%= link_to 'Back to Posts', posts_path %> |