From 3395ebe32097f6c711a3f3f1f44b67b3f969107e Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Fri, 21 Sep 2012 16:49:33 -0500 Subject: add note about AR#include_root_in_json default in Upgrading Rails guide [ci skip] --- guides/source/upgrading_ruby_on_rails.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'guides/source') 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 -- cgit v1.2.3 From 4fc620cc9124cb908a9585dc680b935f3c755dd7 Mon Sep 17 00:00:00 2001 From: Cory Logan Date: Sun, 23 Sep 2012 17:08:35 +0700 Subject: Removed duplicate line describing "default_options". [ci skip] --- guides/source/action_mailer_basics.md | 1 - 1 file changed, 1 deletion(-) (limited to 'guides/source') 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 -- cgit v1.2.3 From 530102f656068274be8e3ea5fc873a3432d8e397 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 24 Sep 2012 15:39:45 -0500 Subject: add a note about DynamicForm in error_messages_for section [ci skip] --- guides/source/i18n.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/i18n.md b/guides/source/i18n.md index f3360156cc..09e89938bb 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. You can install it as a 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. -- cgit v1.2.3 From c9a6c6c8d18006d92a87c2d09bc9d6e5b0b30086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baz=C3=A1n?= Date: Mon, 24 Sep 2012 23:28:02 +0200 Subject: remove duplication --- guides/source/active_record_querying.md | 1 - 1 file changed, 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 2fb0bf1d69..d46b35f8df 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` -- cgit v1.2.3 From f51d95aee52d86b9d6bd8e1d10d35d73349bfc97 Mon Sep 17 00:00:00 2001 From: Igor Zubkov Date: Tue, 25 Sep 2012 01:50:21 +0300 Subject: Fix typo in 4_0_release_notes.md --- guides/source/4_0_release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/4_0_release_notes.md b/guides/source/4_0_release_notes.md index c3921ea541..183715491a 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: -- cgit v1.2.3 From 2029c2ac18c12a08f0ddfdcadf90e50c54520895 Mon Sep 17 00:00:00 2001 From: Bryan Larsen Date: Tue, 25 Sep 2012 13:29:53 -0300 Subject: Update guides/source/routing.md --- guides/source/routing.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'guides/source') 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. -- cgit v1.2.3 From 15d475a63b0beec2e1e735d49103e642ea54dc78 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 26 Sep 2012 07:59:18 -0700 Subject: Remove readonly notice. You need to have @implicit_readonly set for this to happen, and it's false by defualt. Fixes #3386. --- guides/source/active_record_querying.md | 2 -- 1 file changed, 2 deletions(-) (limited to 'guides/source') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index d46b35f8df..1ae6a1f204 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -546,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 -- cgit v1.2.3 From 6ee8e929c30ff7c95bab65bee6e9ce503c3c3331 Mon Sep 17 00:00:00 2001 From: cczona Date: Wed, 26 Sep 2012 13:57:03 -0700 Subject: typo fix: remove duplicate period --- guides/source/asset_pipeline.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') 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. -- cgit v1.2.3 From 7a2b8099efae1f51024dd9a198e8e21fae2071e7 Mon Sep 17 00:00:00 2001 From: Teng Siong Ong Date: Thu, 27 Sep 2012 01:53:04 -0700 Subject: bleakhouse is no longer useful for rails and outdated. --- guides/source/debugging_rails_applications.md | 56 +-------------------------- 1 file changed, 1 insertion(+), 55 deletions(-) (limited to 'guides/source') diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md index 9f8a3d942c..b29b8ba230 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 @@ -726,4 +673,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/) -- cgit v1.2.3 From 46f0fc6968493132da417e3e06f3c8aa09f54038 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Thu, 27 Sep 2012 13:01:21 -0300 Subject: Add #update_columns entry in Rails 4.0 release notes [ci skip] --- guides/source/4_0_release_notes.md | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'guides/source') diff --git a/guides/source/4_0_release_notes.md b/guides/source/4_0_release_notes.md index 183715491a..cce5bc5331 100644 --- a/guides/source/4_0_release_notes.md +++ b/guides/source/4_0_release_notes.md @@ -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: -- cgit v1.2.3 From cf3e760b87c49470c9a26ab3e2da67602474be1f Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Fri, 28 Sep 2012 23:15:09 +0530 Subject: copy editing [ci skip] --- guides/source/i18n.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/i18n.md b/guides/source/i18n.md index 09e89938bb..a3c6b514a4 100644 --- a/guides/source/i18n.md +++ b/guides/source/i18n.md @@ -833,7 +833,7 @@ en: ``` NOTE: In order to use this helper, you need to install [DynamicForm](https://github.com/joelmoss/dynamic_form) -gem. You can install it as a gem by adding this line to your Gemfile: `gem 'dynamic_form'`. +gem by adding this line to your Gemfile: `gem 'dynamic_form'`. ### Overview of Other Built-In Methods that Provide I18n Support -- cgit v1.2.3