From d167cfd62b31333e11fcb9de4ea33dfabde7fa82 Mon Sep 17 00:00:00 2001 From: Jaime Iniesta Date: Thu, 1 Jul 2010 12:10:07 +0200 Subject: Fixes README for generated apps with Rails 3 (rails *new* myapp, and Welcome aboard text) --- railties/README | 4 ++-- railties/lib/rails/generators/rails/app/templates/README | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/railties/README b/railties/README index b8c84dd07d..d8be15e346 100644 --- a/railties/README +++ b/railties/README @@ -29,13 +29,13 @@ link:files/vendor/rails/actionpack/README.html. == Getting Started 1. At the command prompt, create a new Rails application: - rails myapp (where myapp is the application name) + rails new myapp (where myapp is the application name) 2. Change directory to myapp and start the web server: cd myapp; rails server (run with --help for options) 3. Go to http://localhost:3000/ and you'll see: - "Welcome aboard: You're riding the Rails!" + "Welcome aboard: You're riding Ruby on Rails!" 4. Follow the guidelines to start developing your application. You can find the following resources handy: diff --git a/railties/lib/rails/generators/rails/app/templates/README b/railties/lib/rails/generators/rails/app/templates/README index e2764dee03..6966fe987e 100644 --- a/railties/lib/rails/generators/rails/app/templates/README +++ b/railties/lib/rails/generators/rails/app/templates/README @@ -35,7 +35,7 @@ link:files/vendor/rails/actionpack/README.html. cd myapp; rails server (run with --help for options) 3. Go to http://localhost:3000/ and you'll see: - "Welcome aboard: You're riding the Rails!" + "Welcome aboard: You're riding Ruby on Rails!" 4. Follow the guidelines to start developing your application. You can find the following resources handy: -- cgit v1.2.3 From a6913bf7eb614d9e5008cf4230104babfec7c6c4 Mon Sep 17 00:00:00 2001 From: Rizwan Reza Date: Thu, 1 Jul 2010 23:07:24 +0430 Subject: Added documentation for usage of associative resources with form_for --- actionpack/lib/action_view/helpers/form_helper.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index d1b10a9281..6302491c2a 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -213,12 +213,22 @@ module ActionView # ... # <% end %> # - # And for namespaced routes, like +admin_post_url+: + # For namespaced routes, like +admin_post_url+: # # <%= form_for([:admin, @post]) do |f| %> # ... # <% end %> # + # If your resource has associations defined, for example, you want to add comments + # to the post given that the routes are set correctly: + # + # <%= form_for([@document, @comment]) do |f| %> + # ... + # <% end %> + # + # Where +@document = Document.find(params[:id])+ and + # +@comment = Comment.new+. + # # === Unobtrusive JavaScript # # Specifying: -- cgit v1.2.3 From d10aaefcfd4141144eaf971c0560da5631e3dff5 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Thu, 1 Jul 2010 23:06:58 -0400 Subject: clarifying the comments regarding base_class declaration --- activerecord/lib/active_record/base.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index c8795e4496..9860c3c725 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -869,6 +869,9 @@ module ActiveRecord #:nodoc: # Returns the base AR subclass that this class descends from. If A # extends AR::Base, A.base_class will return A. If B descends from A # through some arbitrarily deep hierarchy, B.base_class will return A. + # + # If B < A and C < B and if A is an abstract_class then both B.base_class + # and C.base_class would return B as the answer since A is an abstract_class. def base_class class_of_active_record_descendant(self) end @@ -876,8 +879,7 @@ module ActiveRecord #:nodoc: # Set this to true if this is an abstract class (see abstract_class?). attr_accessor :abstract_class - # Returns whether this class is a base AR class. If A is a base class and - # B descends from A, then B.base_class will return B. + # Returns whether this class is an abstract class or not. def abstract_class? defined?(@abstract_class) && @abstract_class == true end -- cgit v1.2.3 From 5360014a5d77e8b6db71530dae49ac651392536d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=A3is=20Ozols?= Date: Sat, 3 Jul 2010 03:16:04 +0300 Subject: Changed passed argument to :validate => false in validation skipping section. --- railties/guides/source/active_record_validations_callbacks.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile index cfd4ae55cc..84c33e34f9 100644 --- a/railties/guides/source/active_record_validations_callbacks.textile +++ b/railties/guides/source/active_record_validations_callbacks.textile @@ -86,9 +86,9 @@ The following methods skip validations, and will save the object to the database * +update_attribute+ * +update_counters+ -Note that +save+ also has the ability to skip validations if passed +false+ as argument. This technique should be used with caution. +Note that +save+ also has the ability to skip validations if passed +:validate => false+ as argument. This technique should be used with caution. -* +save(false)+ +* +save(:validate => false)+ h4. +valid?+ and +invalid?+ -- cgit v1.2.3 From 52e526a8e3ed3682ae2b774e4a328b9aa8bd6dde Mon Sep 17 00:00:00 2001 From: Andrew White Date: Sat, 3 Jul 2010 09:01:01 +0100 Subject: :singular is no longer a valid option for resources [#5037 state:resolved] --- railties/guides/source/routing.textile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile index 9ff06856c3..3562030aa9 100644 --- a/railties/guides/source/routing.textile +++ b/railties/guides/source/routing.textile @@ -714,14 +714,14 @@ Rails now creates routes to the +CategoriesControlleR+. h4. Overriding the Singular Form -If you want to customize the singular name of the route in the named helpers, you can use the +:singular+ option. +If you want to define the singular form of a resource, you should add additional rules to the +Inflector+. -resources :teeth, :singular => "tooth" +ActiveSupport::Inflector.inflections do |inflect| + inflect.irregular 'tooth', 'teeth' +end -TIP: If you want to define the singular form of a word for your entire application, you should add additional rules to the +Inflector+ instead. - h4(#nested-name-prefix). Using +:name_prefix+ in Nested Resources The +:name_prefix+ option overrides the automatically-generated prefix for the parent resource in nested route helpers. For example, -- cgit v1.2.3 From 547199ee4a279cf885ee6c4e3a605f64f70c9310 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Sat, 3 Jul 2010 09:18:02 +0100 Subject: Updated routing guide to reflect the fact that :name_prefix is now :as --- railties/guides/source/routing.textile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile index 3562030aa9..4e55b07ed7 100644 --- a/railties/guides/source/routing.textile +++ b/railties/guides/source/routing.textile @@ -647,11 +647,11 @@ end h4. Overriding the Named Helper Prefix -You can use the :name_prefix option to add a prefix to the named route helpers that Rails generates for a route. You can use this option to prevent collisions between routes using a path scope. +You can use the :as option to rename the named route helpers that Rails generates for a route. You can use this option to prevent collisions between routes using a path scope. scope "admin" do - resources :photos, :name_prefix => "admin" + resources :photos, :as => "admin_photos" end resources :photos @@ -662,14 +662,14 @@ This will provide route helpers such as +admin_photos_path+, +new_admin_photo_pa You could specify a name prefix to use for a group of routes in the scope: -scope "admin", :name_prefix => "admin" do +scope "admin", :as => "admin" do resources :photos, :accounts end resources :photos, :accounts -NOTE: The +namespace+ scope will automatically add a +:name_prefix+ as well as +:module+ and +:path+ prefixes. +NOTE: The +namespace+ scope will automatically add +:as+ as well as +:module+ and +:path+ prefixes. h4. Restricting the Routes Created @@ -722,13 +722,13 @@ ActiveSupport::Inflector.inflections do |inflect| end -h4(#nested-name-prefix). Using +:name_prefix+ in Nested Resources +h4(#nested-names). Using +:as+ in Nested Resources -The +:name_prefix+ option overrides the automatically-generated prefix for the parent resource in nested route helpers. For example, +The +:as+ option overrides the automatically-generated name for the resource in nested route helpers. For example, resources :magazines do - resources :ads, :name_prefix => 'periodical' + resources :ads, :as => 'periodical_ads' end -- cgit v1.2.3 From a7988fcf4149ab61c83ade5d380ae5d30789efc8 Mon Sep 17 00:00:00 2001 From: Jeff Dean Date: Sun, 4 Jul 2010 00:35:34 -0400 Subject: Added release notes for 3 changes to helpers --- railties/guides/source/3_0_release_notes.textile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/railties/guides/source/3_0_release_notes.textile b/railties/guides/source/3_0_release_notes.textile index b32ca4fce9..7dcaf508c6 100644 --- a/railties/guides/source/3_0_release_notes.textile +++ b/railties/guides/source/3_0_release_notes.textile @@ -339,7 +339,9 @@ h5. Other Changes * You no longer need to place a minus sign at the end of a ruby interpolation inside an ERb template to remove the trailing carriage return in the HTML output. * Added +grouped_collection_select+ helper to Action View. * +content_for?+ has been added allowing you to check for the existence of content in a view before rendering. - +* passing +:value => nil+ to form helpers will set the field's +value+ attribute to nil as opposed to using the default value +* passing +:id => nil+ to form helpers will cause those fields to be rendered with no +id+ attribute +* passing +:alt => nil+ to +image_tag+ will cause the +img+ tag to render with no +alt+ attribute h3. Active Model -- cgit v1.2.3 From 7d04a4be6b744fd1de9dc906a2faf83fffc9e0cc Mon Sep 17 00:00:00 2001 From: Andrew White Date: Sun, 4 Jul 2010 08:05:11 +0100 Subject: Reword routing guide so that we talk about prefixing as a use of :as rather than as a specific prefixing option (which :name_prefix used to be). --- railties/guides/source/routing.textile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile index 4e55b07ed7..00755071c5 100644 --- a/railties/guides/source/routing.textile +++ b/railties/guides/source/routing.textile @@ -645,9 +645,9 @@ scope :path_names => { :new => "make" } do end -h4. Overriding the Named Helper Prefix +h4. Prefixing the Named Route Helpers -You can use the :as option to rename the named route helpers that Rails generates for a route. You can use this option to prevent collisions between routes using a path scope. +You can use the +:as+ option to prefix the named route helpers that Rails generates for a route. Use this option to prevent name collisions between routes using a path scope. scope "admin" do @@ -659,7 +659,7 @@ resources :photos This will provide route helpers such as +admin_photos_path+, +new_admin_photo_path+ etc. -You could specify a name prefix to use for a group of routes in the scope: +To prefix a group of routes, use +:as+ with +scope+: scope "admin", :as => "admin" do -- cgit v1.2.3 From db0530e4ba48f20cd42b781d053cdb23e5e7d210 Mon Sep 17 00:00:00 2001 From: Mark Hayes Date: Mon, 5 Jul 2010 19:28:58 -0700 Subject: Fixed typo in Rails::Generators::Base [#5051 state:resolved] --- railties/lib/rails/generators/actions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 199afbdc30..a27d38e23a 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -267,7 +267,7 @@ module Rails ActiveSupport::Deprecation.warn "freeze! is deprecated since your rails app now comes bundled with Rails by default, please check your Gemfile" end - # Make an entry in Rails routing file conifg/routes.rb + # Make an entry in Rails routing file config/routes.rb # # === Example # -- cgit v1.2.3 From e5c95b1871da61984b4cd109e39b605c447323dd Mon Sep 17 00:00:00 2001 From: l4u Date: Tue, 6 Jul 2010 21:15:14 +0800 Subject: Fixed minor typo app/view to app/views --- railties/guides/source/getting_started.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile index 6abb3ed9f4..f547f29087 100644 --- a/railties/guides/source/getting_started.textile +++ b/railties/guides/source/getting_started.textile @@ -958,7 +958,7 @@ You'll see a bit more complexity here than you did in the controller for posts. In addition, the code takes advantage of some of the methods available for an association. We use the +create+ method on +@post.comments+ to create and save the comment. This will automatically link the comment so that it belongs to that particular post. -Once we have made the new comment, we send the user back to the original post using the +post_path(@post)+ helper. As we have already seen, this calls the +show+ action of the +PostsController+ which in turn renders the +show.html.erb+ template. This is where we want the comment to show, so let's add that to the +app/view/posts/show.html.erb+. +Once we have made the new comment, we send the user back to the original post using the +post_path(@post)+ helper. As we have already seen, this calls the +show+ action of the +PostsController+ which in turn renders the +show.html.erb+ template. This is where we want the comment to show, so let's add that to the +app/views/posts/show.html.erb+.

<%= notice %>

-- cgit v1.2.3 From c1fc59c7ac1726f54d54b2896004997892e15ec9 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Tue, 6 Jul 2010 10:09:54 -0400 Subject: added more info about << operation in associations --- activerecord/lib/active_record/associations.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 4caa434fc0..49da8595b2 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -763,6 +763,8 @@ module ActiveRecord # An empty array is returned if none are found. # [collection<<(object, ...)] # Adds one or more objects to the collection by setting their foreign keys to the collection's primary key. + # Note that this operation instantly fires update sql without waiting for the save or update call on the + # parent object. # [collection.delete(object, ...)] # Removes one or more objects from the collection by setting their foreign keys to +NULL+. # Objects will be in addition destroyed if they're associated with :dependent => :destroy, @@ -1186,6 +1188,8 @@ module ActiveRecord # [collection<<(object, ...)] # Adds one or more objects to the collection by creating associations in the join table # (collection.push and collection.concat are aliases to this method). + # Note that this operation instantly fires update sql without waiting for the save or update call on the + # parent object. # [collection.delete(object, ...)] # Removes one or more objects from the collection by removing their associations from the join table. # This does not destroy the objects. -- cgit v1.2.3 From 0f96cea322294f84df34c43000443b249a880126 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Wed, 7 Jul 2010 05:31:54 +0100 Subject: Add note about incompatibility of namespace and :controller --- railties/guides/source/routing.textile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile index 00755071c5..72a76e25bb 100644 --- a/railties/guides/source/routing.textile +++ b/railties/guides/source/routing.textile @@ -382,6 +382,12 @@ match ':controller/:action/:id/:user_id' An incoming URL of +/photos/show/1/2+ will be dispatched to the +show+ action of the +PhotosController+. +params[:id]+ will be +"1"+, and +params[:user_id]+ will be +"2"+. +NOTE: You can't use +namespace+ or +:module+ with a +:controller+ path segment. If you need to do this then use a constraint on :controller that matches the namespace you require. e.g: + + +match ':controller(/:action(/:id))', :controller => /admin\/[^\/]+/ + + h4. Static Segments You can specify static segments when creating a route: -- cgit v1.2.3