Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lifo/docrails
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeraj Singh committed Jul 6, 2010
2 parents c1fc59c + e5c95b1 commit ffdbe56
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
4 changes: 3 additions & 1 deletion railties/guides/source/3_0_release_notes.textile
Expand Up @@ -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

Expand Down
Expand Up @@ -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?+

Expand Down
2 changes: 1 addition & 1 deletion railties/guides/source/getting_started.textile
Expand Up @@ -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+.

<erb>
<p class="notice"><%= notice %></p>
Expand Down
26 changes: 13 additions & 13 deletions railties/guides/source/routing.textile
Expand Up @@ -645,31 +645,31 @@ scope :path_names => { :new => "make" } do
end
</ruby>

h4. Overriding the Named Helper Prefix
h4. Prefixing the Named Route Helpers

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 prefix the named route helpers that Rails generates for a route. Use this option to prevent name collisions between routes using a path scope.

<ruby>
scope "admin" do
resources :photos, :name_prefix => "admin"
resources :photos, :as => "admin_photos"
end

resources :photos
</ruby>

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+:

<ruby>
scope "admin", :name_prefix => "admin" do
scope "admin", :as => "admin" do
resources :photos, :accounts
end

resources :photos, :accounts
</ruby>

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

Expand Down Expand Up @@ -714,21 +714,21 @@ 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+.

<ruby>
resources :teeth, :singular => "tooth"
ActiveSupport::Inflector.inflections do |inflect|
inflect.irregular 'tooth', 'teeth'
end
</ruby>

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
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,

<ruby>
resources :magazines do
resources :ads, :name_prefix => 'periodical'
resources :ads, :as => 'periodical_ads'
end
</ruby>

Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/generators/actions.rb
Expand Up @@ -267,7 +267,7 @@ def freeze!(args={})
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
#
Expand Down

0 comments on commit ffdbe56

Please sign in to comment.