From 2801efbc3b3a5c5cf3406aa7063852a86898f547 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 25 Dec 2010 23:59:57 +0530 Subject: use all and first instead of find(:all) and find(:first) --- railties/guides/source/action_view_overview.textile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'railties/guides/source/action_view_overview.textile') diff --git a/railties/guides/source/action_view_overview.textile b/railties/guides/source/action_view_overview.textile index 30faeeaa91..ffcc98f41b 100644 --- a/railties/guides/source/action_view_overview.textile +++ b/railties/guides/source/action_view_overview.textile @@ -367,14 +367,14 @@ This helper makes building an ATOM feed easy. Here's a full usage example: *config/routes.rb* -map.resources :posts +resources :posts *app/controllers/posts_controller.rb* def index - @posts = Post.find(:all) + @posts = Post.all respond_to do |format| format.html @@ -809,7 +809,7 @@ end Sample usage (selecting the associated Author for an instance of Post, +@post+): -collection_select(:post, :author_id, Author.find(:all), :id, :name_with_initial, {:prompt => true}) +collection_select(:post, :author_id, Author.all, :id, :name_with_initial, {:prompt => true}) If @post.author_id is already 1, this would return: @@ -910,7 +910,7 @@ Create a select tag and a series of contained option tags for the provided objec Example with @post.person_id => 1: -select("post", "person_id", Person.find(:all).collect {|p| [ p.name, p.id ] }, { :include_blank => true }) +select("post", "person_id", Person.all.collect {|p| [ p.name, p.id ] }, { :include_blank => true }) could become: -- cgit v1.2.3 From 9ed385fe1798bd469144c57dbfd89db6781d4ad6 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sun, 26 Dec 2010 00:09:08 +0530 Subject: fix formatting --- railties/guides/source/action_view_overview.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source/action_view_overview.textile') diff --git a/railties/guides/source/action_view_overview.textile b/railties/guides/source/action_view_overview.textile index ffcc98f41b..e1fc0e7732 100644 --- a/railties/guides/source/action_view_overview.textile +++ b/railties/guides/source/action_view_overview.textile @@ -439,7 +439,7 @@ The +capture+ method allows you to extract part of a template into a variable. Y <% @greeting = capture do %>

Welcome! The date and time is <%= Time.now %>

<% end %> - + The captured variable can then be used anywhere else. -- cgit v1.2.3