aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorVijay Dev <vijaydev.cse@gmail.com>2012-09-28 23:17:07 +0530
committerVijay Dev <vijaydev.cse@gmail.com>2012-09-28 23:17:07 +0530
commit955a72c692a4298d238cc2e6353b9874099203f1 (patch)
tree2a05fecd15526cd0013c22e45825be1aca4844d9 /guides
parent77fbe1c0199567486c422fdf5cce49f2c11fc953 (diff)
parentcf3e760b87c49470c9a26ab3e2da67602474be1f (diff)
downloadrails-955a72c692a4298d238cc2e6353b9874099203f1.tar.gz
rails-955a72c692a4298d238cc2e6353b9874099203f1.tar.bz2
rails-955a72c692a4298d238cc2e6353b9874099203f1.zip
Merge branch 'master' of github.com:lifo/docrails
Conflicts: actionpack/lib/action_view/helpers/asset_tag_helper.rb
Diffstat (limited to 'guides')
-rw-r--r--guides/source/4_0_release_notes.md10
-rw-r--r--guides/source/action_mailer_basics.md1
-rw-r--r--guides/source/active_record_querying.md3
-rw-r--r--guides/source/asset_pipeline.md2
-rw-r--r--guides/source/debugging_rails_applications.md56
-rw-r--r--guides/source/i18n.md6
-rw-r--r--guides/source/routing.md12
-rw-r--r--guides/source/upgrading_ruby_on_rails.md16
8 files changed, 43 insertions, 63 deletions
diff --git a/guides/source/4_0_release_notes.md b/guides/source/4_0_release_notes.md
index c3921ea541..cce5bc5331 100644
--- a/guides/source/4_0_release_notes.md
+++ b/guides/source/4_0_release_notes.md
@@ -538,7 +538,7 @@ Active Record
* `mysql` and `mysql2` connections will set `SQL_MODE=STRICT_ALL_TABLES` by default to avoid silent data loss. This can be disabled by specifying `strict: false` in `config/database.yml`.
-* Added default order to `ActiveRecord::Base#first` to assure consistent results among diferent database engines. Introduced `ActiveRecord::Base#take` as a replacement to the old behavior.
+* Added default order to `ActiveRecord::Base#first` to assure consistent results among different database engines. Introduced `ActiveRecord::Base#take` as a replacement to the old behavior.
* Added an `:index` option to automatically create indexes for `references` and `belongs_to` statements in migrations. This can be either a boolean or a hash that is identical to options available to the `add_index` method:
@@ -652,6 +652,14 @@ Active Record
* PostgreSQL hstore types are automatically deserialized from the database.
+* Added `#update_columns` method which updates the attributes from the passed-in hash without calling save, hence skipping validations and callbacks. `ActiveRecordError` will be raised when called on new objects or when at least one of the attributes is marked as read only.
+
+ ```ruby
+ post.attributes # => {"id"=>2, "title"=>"My title", "body"=>"My content", "author"=>"Peter"}
+ post.update_columns({title: 'New title', author: 'Sebastian'}) # => true
+ post.attributes # => {"id"=>2, "title"=>"New title", "body"=>"My content", "author"=>"Sebastian"}
+ ```
+
### Deprecations
* Deprecated most of the 'dynamic finder' methods. All dynamic methods except for `find_by_...` and `find_by_...!` are deprecated. Here's how you can rewrite the code:
diff --git a/guides/source/action_mailer_basics.md b/guides/source/action_mailer_basics.md
index de5c15fe54..5e731d0a18 100644
--- a/guides/source/action_mailer_basics.md
+++ b/guides/source/action_mailer_basics.md
@@ -482,7 +482,6 @@ The following configuration options are best made in one of the environment file
|`deliveries`|Keeps an array of all the emails sent out through the Action Mailer with delivery_method :test. Most useful for unit and functional testing.|
|`default_options`|Allows you to set default values for the `mail` method options (`:from`, `:reply_to`, etc.).|
|`async`|Setting this flag will turn on asynchronous message sending, message rendering and delivery will be pushed to `Rails.queue` for processing.|
-|`default_options`|Allows you to set default values for the `mail` method options (`:from`, `:reply_to`, etc.).|
### Example Action Mailer Configuration
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index 2fb0bf1d69..1ae6a1f204 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -68,7 +68,6 @@ The methods are:
* `none`
* `offset`
* `order`
-* `none`
* `preload`
* `readonly`
* `references`
@@ -547,8 +546,6 @@ By default, `Model.find` selects all the fields from the result set using `selec
To select only a subset of fields from the result set, you can specify the subset via the `select` method.
-NOTE: If the `select` method is used, all the returning objects will be [read only](#readonly-objects).
-
For example, to select only `viewable_by` and `locked` columns:
```ruby
diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md
index be7ca5107d..fc0092a93e 100644
--- a/guides/source/asset_pipeline.md
+++ b/guides/source/asset_pipeline.md
@@ -42,7 +42,7 @@ The first feature of the pipeline is to concatenate assets. This is important in
Rails 2.x introduced the ability to concatenate JavaScript and CSS assets by placing `:cache => true` at the end of the `javascript_include_tag` and `stylesheet_link_tag` methods. But this technique has some limitations. For example, it cannot generate the caches in advance, and it is not able to transparently include assets provided by third-party libraries.
-Starting with version 3.1, Rails defaults to concatenating all JavaScript files into one master `.js` file and all CSS files into one master `.css` file. As you'll learn later in this guide, you can customize this strategy to group files any way you like. In production, Rails inserts an MD5 fingerprint into each filename so that the file is cached by the web browser. You can invalidate the cache by altering this fingerprint, which happens automatically whenever you change the file contents..
+Starting with version 3.1, Rails defaults to concatenating all JavaScript files into one master `.js` file and all CSS files into one master `.css` file. As you'll learn later in this guide, you can customize this strategy to group files any way you like. In production, Rails inserts an MD5 fingerprint into each filename so that the file is cached by the web browser. You can invalidate the cache by altering this fingerprint, which happens automatically whenever you change the file contents.
The second feature of the asset pipeline is asset minification or compression. For CSS files, this is done by removing whitespace and comments. For JavaScript, more complex processes can be applied. You can choose from a set of built in options or specify your own.
diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md
index 3651ec5ad8..a72f54a1b8 100644
--- a/guides/source/debugging_rails_applications.md
+++ b/guides/source/debugging_rails_applications.md
@@ -638,60 +638,7 @@ Debugging Memory Leaks
A Ruby application (on Rails or not), can leak memory - either in the Ruby code or at the C code level.
-In this section, you will learn how to find and fix such leaks by using tools such as BleakHouse and Valgrind.
-
-### BleakHouse
-
-[BleakHouse](https://github.com/evan/bleak_house/) is a library for finding memory leaks.
-
-If a Ruby object does not go out of scope, the Ruby Garbage Collector won't sweep it since it is referenced somewhere. Leaks like this can grow slowly and your application will consume more and more memory, gradually affecting the overall system performance. This tool will help you find leaks on the Ruby heap.
-
-To install it run:
-
-```bash
-$ gem install bleak_house
-```
-
-Then setup your application for profiling. Then add the following at the bottom of config/environment.rb:
-
-```ruby
-require 'bleak_house' if ENV['BLEAK_HOUSE']
-```
-
-Start a server instance with BleakHouse integration:
-
-```bash
-$ RAILS_ENV=production BLEAK_HOUSE=1 ruby-bleak-house rails server
-```
-
-Make sure to run a couple hundred requests to get better data samples, then press `CTRL-C`. The server will stop and Bleak House will produce a dumpfile in `/tmp`:
-
-```
-** BleakHouse: working...
-** BleakHouse: complete
-** Bleakhouse: run 'bleak /tmp/bleak.5979.0.dump' to analyze.
-```
-
-To analyze it, just run the listed command. The top 20 leakiest lines will be listed:
-
-```
- 191691 total objects
- Final heap size 191691 filled, 220961 free
- Displaying top 20 most common line/class pairs
- 89513 __null__:__null__:__node__
- 41438 __null__:__null__:String
- 2348 /opt/local//lib/ruby/site_ruby/1.8/rubygems/specification.rb:557:Array
- 1508 /opt/local//lib/ruby/gems/1.8/specifications/gettext-1.90.0.gemspec:14:String
- 1021 /opt/local//lib/ruby/gems/1.8/specifications/heel-0.2.0.gemspec:14:String
- 951 /opt/local//lib/ruby/site_ruby/1.8/rubygems/version.rb:111:String
- 935 /opt/local//lib/ruby/site_ruby/1.8/rubygems/specification.rb:557:String
- 834 /opt/local//lib/ruby/site_ruby/1.8/rubygems/version.rb:146:Array
- ...
-```
-
-This way you can find where your application is leaking memory and fix it.
-
-If [BleakHouse](https://github.com/evan/bleak_house/) doesn't report any heap growth but you still have memory growth, you might have a broken C extension, or real leak in the interpreter. In that case, try using Valgrind to investigate further.
+In this section, you will learn how to find and fix such leaks by using tool such as Valgrind.
### Valgrind
@@ -724,4 +671,3 @@ References
* [Debugging with ruby-debug](http://bashdb.sourceforge.net/ruby-debug.html)
* [ruby-debug cheat sheet](http://cheat.errtheblog.com/s/rdebug/)
* [Ruby on Rails Wiki: How to Configure Logging](http://wiki.rubyonrails.org/rails/pages/HowtoConfigureLogging)
-* [Bleak House Documentation](http://blog.evanweaver.com/files/doc/fauna/bleak_house/)
diff --git a/guides/source/i18n.md b/guides/source/i18n.md
index f3360156cc..a3c6b514a4 100644
--- a/guides/source/i18n.md
+++ b/guides/source/i18n.md
@@ -816,7 +816,8 @@ So, for example, instead of the default error message `"can not be blank"` you c
#### Translations for the Active Record `error_messages_for` Helper
-If you are using the Active Record `error_messages_for` helper, you will want to add translations for it.
+If you are using the Active Record `error_messages_for` helper, you will want to add
+translations for it.
Rails ships with the following translations:
@@ -831,6 +832,9 @@ en:
body: "There were problems with the following fields:"
```
+NOTE: In order to use this helper, you need to install [DynamicForm](https://github.com/joelmoss/dynamic_form)
+gem by adding this line to your Gemfile: `gem 'dynamic_form'`.
+
### Overview of Other Built-In Methods that Provide I18n Support
Rails uses fixed strings and other localizations, such as format strings and other format information in a couple of helpers. Here's a brief overview.
diff --git a/guides/source/routing.md b/guides/source/routing.md
index 27fd2a35c4..3acb7fa0e5 100644
--- a/guides/source/routing.md
+++ b/guides/source/routing.md
@@ -401,6 +401,18 @@ resources :photos do
end
```
+#### Adding Routes for Additional New Actions
+
+To add an alternate new action using the `:on` shortcut:
+
+```ruby
+resources :comments do
+ get 'preview', :on => :new
+end
+```
+
+This will enable Rails to recognize paths such as `/comments/new/preview` with GET, and route to the `preview` action of `CommentsController`. It will also create the `preview_new_comment_url` and `preview_new_comment_path` route helpers.
+
#### A Note of Caution
If you find yourself adding many extra actions to a resourceful route, it's time to stop and ask yourself whether you're disguising the presence of another resource.
diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md
index 1eb8ff2f59..d6c425a356 100644
--- a/guides/source/upgrading_ruby_on_rails.md
+++ b/guides/source/upgrading_ruby_on_rails.md
@@ -51,7 +51,21 @@ Rails 4.0 has changed `serialized_attributes` and `attr_readonly` to class metho
### Active Model
-Rails 4.0 has changed how errors attach with the `ActiveModel::Validations::ConfirmationValidator`. Now when confirmation validations fail the error will be attached to `:#{attribute}_confirmation` instead of `attribute`.
+Rails 4.0 has changed how errors attach with the `ActiveModel::Validations::ConfirmationValidator`.
+Now when confirmation validations fail the error will be attached to
+`:#{attribute}_confirmation` instead of `attribute`.
+
+Rails 4.0 has changed `ActiveModel::Serializers::JSON.include_root_in_json` default
+value to `false`. Now, Active Model Serializers and Active Record objects have the
+same default behaviour. This means that you can comment or remove the following option
+in the `config/initializers/wrap_parameters.rb` file:
+
+```ruby
+# Disable root element in JSON by default.
+# ActiveSupport.on_load(:active_record) do
+# self.include_root_in_json = false
+# end
+```
### Action Pack