From 69c5b40491e5e13672f21eee7311d5e46be2b433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Blais=20Masson?= Date: Sun, 24 Mar 2013 23:15:37 -0400 Subject: [PATCH 01/49] =?UTF-8?q?Remove=20=E2=80=9CSweepers=E2=80=9D=20fro?= =?UTF-8?q?m=20Caching=20TOC=20and=20mention=20Page/Action=20caching=20are?= =?UTF-8?q?=20removed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- guides/source/caching_with_rails.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index abab3dd983..e1fc3d0f53 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -5,8 +5,8 @@ This guide will teach you what you need to know about avoiding that expensive ro After reading this guide, you will know: -* Page, action, and fragment caching. -* Sweepers. +* Page and action caching (moved to separate gems as of Rails 4). +* Fragment caching. * Alternative cache stores. * Conditional GET support. From 06e22c01e86e47ebe0835e4c6ec351175cf91b96 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 30 Mar 2013 15:12:23 +0530 Subject: [PATCH 02/49] Revert "Using American English spellings over British style spellings" This reverts commit 573df1cf2a5d5d1f288c8a4a5d76194675141832. Reason: changelog edits aren't allowed in docrails. [ci skip] --- activesupport/CHANGELOG.md | 6 +++--- guides/source/upgrading_ruby_on_rails.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index f5042ed170..9d26b8ba3e 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -74,7 +74,7 @@ * Improve `String#squish` to handle Unicode whitespace. *Antoine Lyset* -* Standardize on `to_time` returning an instance of `Time` in the local system timezone +* Standardise on `to_time` returning an instance of `Time` in the local system timezone across `String`, `Time`, `Date`, `DateTime` and `ActiveSupport::TimeWithZone`. *Andrew White* @@ -140,7 +140,7 @@ * Remove surrogate unicode character encoding from `ActiveSupport::JSON.encode` The encoding scheme was broken for unicode characters outside the basic multilingual plane; - since JSON is assumed to be UTF-8, and we already force the encoding to UTF-8, + since json is assumed to be UTF-8, and we already force the encoding to UTF-8, simply pass through the un-encoded characters. *Brett Carter* @@ -359,7 +359,7 @@ * An optional block can be passed to `HashWithIndifferentAccess#update` and `#merge`. The block will be invoked for each duplicated key, and used to resolve the conflict, - thus replicating the behavior of the corresponding methods on the `Hash` class. + thus replicating the behaviour of the corresponding methods on the `Hash` class. *Leo Cassarani* diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index 62e2624434..8961f08c0b 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -93,7 +93,7 @@ Rails 4.0 extracted Active Resource to its own gem. If you still need the featur * 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 behavior. This means that you can comment or remove the following option in the `config/initializers/wrap_parameters.rb` file: +* 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. @@ -310,7 +310,7 @@ config.assets.debug = true Again, most of the changes below are for the asset pipeline. You can read more about these in the [Asset Pipeline](asset_pipeline.html) guide. ```ruby -# Compress JavaScript and CSS +# Compress JavaScripts and CSS config.assets.compress = true # Don't fallback to assets pipeline if a precompiled asset is missed From 805c4c1e134bd36573d7d349a180b17dd1d77b7c Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Sat, 30 Mar 2013 08:12:53 -0400 Subject: [PATCH 03/49] minor copy editing --- activerecord/lib/active_record/associations/association.rb | 2 +- .../lib/active_record/associations/collection_proxy.rb | 4 ++-- activerecord/lib/active_record/reflection.rb | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb index f3f4792eaa..1b9dbb1790 100644 --- a/activerecord/lib/active_record/associations/association.rb +++ b/activerecord/lib/active_record/associations/association.rb @@ -30,7 +30,7 @@ module ActiveRecord reset_scope end - # Returns the name of the table of the related class: + # Returns the name of the table of the associated class: # # post.comments.aliased_table_name # => "comments" # diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index c2add32aa6..fd084548c5 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -92,7 +92,7 @@ module ActiveRecord # # => ActiveModel::MissingAttributeError: missing attribute: person_id # # *Second:* You can pass a block so it can be used just like Array#select. - # This build an array of objects from the database for the scope, + # This builds an array of objects from the database for the scope, # converting them into an array and iterating through them using # Array#select. # @@ -303,7 +303,7 @@ module ActiveRecord @association.concat(*records) end - # Replace this collection with +other_array+. This will perform a diff + # Replaces this collection with +other_array+. This will perform a diff # and delete/add only records that have changed. # # class Person < ActiveRecord::Base diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 0995750ecd..bbad106f8b 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -75,8 +75,13 @@ module ActiveRecord end end - # Abstract base class for AggregateReflection and AssociationReflection. Objects of + # Base class for AggregateReflection and AssociationReflection. Objects of # AggregateReflection and AssociationReflection are returned by the Reflection::ClassMethods. + # + # MacroReflection + # AggregateReflection + # AssociationReflection + # ThroughReflection class MacroReflection # Returns the name of the macro. # From 75afe19182de35ce17afe5c8432ec2d87add42b0 Mon Sep 17 00:00:00 2001 From: Carson McDonald Date: Sun, 31 Mar 2013 09:38:14 -0400 Subject: [PATCH 04/49] Fix typo --- actionpack/lib/action_view/helpers/asset_tag_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 31e37893c6..bb62b45e44 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -67,7 +67,7 @@ module ActionView # you don't specify an extension, .css will be appended automatically. # You can modify the link attributes by passing a hash as the last argument. # For historical reasons, the 'media' attribute will always be present and defaults - # to "screen", so you must explicitely set it to "all" for the stylesheet(s) to + # to "screen", so you must explicitly set it to "all" for the stylesheet(s) to # apply to all media types. # # stylesheet_link_tag "style" From da9031ae26d5b377a465aae925f1c3cc9d2c2453 Mon Sep 17 00:00:00 2001 From: Jonathan Roes Date: Sun, 31 Mar 2013 19:12:06 -0300 Subject: [PATCH 05/49] Remove unnecessary / confusing code in example --- guides/source/action_controller_overview.md | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md index 5e99063da8..5e336fffcd 100644 --- a/guides/source/action_controller_overview.md +++ b/guides/source/action_controller_overview.md @@ -561,7 +561,7 @@ Note that while for session values you set the key to `nil`, to delete a cookie Rendering xml and json data --------------------------- -ActionController makes it extremely easy to render `xml` or `json` data. If you generate a controller using scaffolding then it would look something like this: +ActionController makes it extremely easy to render `xml` or `json` data. If you've generated a controller using scaffolding, it would look something like this: ```ruby class UsersController < ApplicationController @@ -576,7 +576,7 @@ class UsersController < ApplicationController end ``` -Notice that in the above case code is `render xml: @users` and not `render xml: @users.to_xml`. That is because if the input is not string then rails automatically invokes `to_xml` . +You may notice in the above code that we're using `render xml: @users`, not `render xml: @users.to_xml`. If the object is not a String, then Rails will automatically invoke `to_xml` for us. Filters ------- @@ -599,15 +599,6 @@ class ApplicationController < ActionController::Base redirect_to new_login_url # halts request cycle end end - - # The logged_in? method simply returns true if the user is logged - # in and false otherwise. It does this by "booleanizing" the - # current_user method we created previously using a double ! operator. - # Note that this is not common in Ruby and is discouraged unless you - # really mean to convert something into true or false. - def logged_in? - !!current_user - end end ``` From 62b9723fbf166f441316e6ed53bb96b8e2995027 Mon Sep 17 00:00:00 2001 From: Les Nightingill Date: Sun, 31 Mar 2013 18:21:41 -0700 Subject: [PATCH 06/49] as of Rails 3.2.13 it appears that importing an engine's migration into the host app is achieved by rake blorgh_engine:install:migrations --- guides/source/engines.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/engines.md b/guides/source/engines.md index ac76f00832..22c090e04b 100644 --- a/guides/source/engines.md +++ b/guides/source/engines.md @@ -461,7 +461,7 @@ NOTE: Other engines, such as Devise, handle this a little differently by making The engine contains migrations for the `blorgh_posts` and `blorgh_comments` table which need to be created in the application's database so that the engine's models can query them correctly. To copy these migrations into the application use this command: ```bash -$ rake blorgh:install:migrations +$ rake blorgh_engine:install:migrations ``` If you have multiple engines that need migrations copied over, use `railties:install:migrations` instead: From 8429a75418f266c3219d61464e05f5d430b965de Mon Sep 17 00:00:00 2001 From: Ken Lu Date: Sun, 31 Mar 2013 23:48:32 -0400 Subject: [PATCH 07/49] fixed a article link at sitepoint --- guides/source/debugging_rails_applications.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md index 6699098e51..31f96372ec 100644 --- a/guides/source/debugging_rails_applications.md +++ b/guides/source/debugging_rails_applications.md @@ -665,7 +665,7 @@ References * [ruby-debug Homepage](http://bashdb.sourceforge.net/ruby-debug/home-page.html) * [debugger Homepage](https://github.com/cldwalker/debugger) -* [Article: Debugging a Rails application with ruby-debug](http://www.sitepoint.com/article/debug-rails-app-ruby-debug/) +* [Article: Debugging a Rails application with ruby-debug](http://www.sitepoint.com/debug-rails-app-ruby-debug/) * [ruby-debug Basics screencast](http://brian.maybeyoureinsane.net/blog/2007/05/07/ruby-debug-basics-screencast/) * [Ryan Bates' debugging ruby (revised) screencast](http://railscasts.com/episodes/54-debugging-ruby-revised) * [Ryan Bates' stack trace screencast](http://railscasts.com/episodes/24-the-stack-trace) From bff281e759e4fb4353391f002300de49795c5c61 Mon Sep 17 00:00:00 2001 From: Jonathan Roes Date: Mon, 1 Apr 2013 13:53:21 -0300 Subject: [PATCH 08/49] Proofreading tweaks to the Mailer guide --- guides/source/action_mailer_basics.md | 30 +++++++++++++-------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/guides/source/action_mailer_basics.md b/guides/source/action_mailer_basics.md index a0d962f9c4..698fe30722 100644 --- a/guides/source/action_mailer_basics.md +++ b/guides/source/action_mailer_basics.md @@ -14,7 +14,7 @@ After reading this guide, you will know: Introduction ------------ -Action Mailer allows you to send emails from your application using a mailer model and views. So, in Rails, emails are used by creating mailers that inherit from `ActionMailer::Base` and live in `app/mailers`. Those mailers have associated views that appear alongside controller views in `app/views`. +Action Mailer allows you to send emails from your application using mailer classes and views. Mailers work very similarly to controllers. They inherit from `ActionMailer::Base` and live in `app/mailers`, and they have associated views that appear in `app/views`. Sending Emails -------------- @@ -34,7 +34,7 @@ invoke test_unit create test/mailers/user_mailer_test.rb ``` -So we got the mailer, the views, and the tests. +A mailer, a views subdirectory, and tests were created. #### Edit the Mailer @@ -46,7 +46,7 @@ class UserMailer < ActionMailer::Base end ``` -Let's add a method called `welcome_email`, that will send an email to the user's registered email address: +Let's add a method called `welcome_email` that will send an email to the user's registered email address: ```ruby class UserMailer < ActionMailer::Base @@ -62,7 +62,7 @@ end Here is a quick explanation of the items presented in the preceding method. For a full list of all available options, please have a look further down at the Complete List of Action Mailer user-settable attributes section. -* `default Hash` - This is a hash of default values for any email you send, in this case we are setting the `:from` header to a value for all messages in this class, this can be overridden on a per email basis +* `default Hash` - This is a hash of default values for any email you send from this mailer. In this case we are setting the `:from` header to a value for all messages in this class. This can be overridden on a per-email basis. * `mail` - The actual email message, we are passing the `:to` and `:subject` headers in. Just like controllers, any instance variables we define in the method become available for use in the views. @@ -91,7 +91,7 @@ Create a file called `welcome_email.html.erb` in `app/views/user_mailer/`. This ``` -It is also a good idea to make a text part for this email. To do this, create a file called `welcome_email.text.erb` in `app/views/user_mailer/`: +It is also a good idea to make a text template for this email. To do this, create a file called `welcome_email.text.erb` in `app/views/user_mailer/`: ```erb Welcome to example.com, <%= @user.name %> @@ -109,18 +109,18 @@ When you call the `mail` method now, Action Mailer will detect the two templates #### Wire It Up So That the System Sends the Email When a User Signs Up -There are several ways to do this, some people create Rails Observers to fire off emails, others do it inside of the User Model. However, mailers are really just another way to render a view. Instead of rendering a view and sending out the HTTP protocol, they are just sending it out through the Email protocols instead. Due to this, it makes sense to just have your controller tell the mailer to send an email when a user is successfully created. +There are several ways to do this. Some people create Rails Observers to fire off emails when things change in your application, others do it using model callbacks. However, mailers are really just another way to render a view. Instead of rendering a view and sending out the HTTP protocol, they are just sending it out through the Email protocol instead. Due to this, it makes sense to just have your controller tell the mailer to send an email when a user is successfully created. Setting this up is painfully simple. -First off, we need to create a simple `User` scaffold: +First, let's create a simple `User` scaffold: ```bash $ rails generate scaffold user name email login $ rake db:migrate ``` -Now that we have a user model to play with, we will just edit the `app/controllers/users_controller.rb` make it instruct the UserMailer to deliver an email to the newly created user by editing the create action and inserting a call to `UserMailer.welcome_email` right after the user is successfully saved: +Now that we have a user model to play with, we will just edit the `app/controllers/users_controller.rb` to make it instruct the UserMailer to deliver an email to the newly created user by editing the create action and inserting a call to `UserMailer.welcome_email` right after the user is successfully saved: ```ruby class UsersController < ApplicationController @@ -145,7 +145,7 @@ class UsersController < ApplicationController end ``` -This provides a much simpler implementation that does not require the registering of observers and the like. +This provides a simple implementation that does not require the registering of observers or creation of model callbacks. The method `welcome_email` returns a `Mail::Message` object which can then just be told `deliver` to send itself out. @@ -216,7 +216,7 @@ NOTE: If you specify an encoding, Mail will assume that your content is already Action Mailer 3.0 makes inline attachments, which involved a lot of hacking in pre 3.0 versions, much simpler and trivial as they should be. -* Firstly, to tell Mail to turn an attachment into an inline attachment, you just call `#inline` on the attachments method within your Mailer: +* First, to tell Mail to turn an attachment into an inline attachment, you just call `#inline` on the attachments method within your Mailer: ```ruby def welcome @@ -262,7 +262,7 @@ The same format can be used to set carbon copy (Cc:) and blind carbon copy (Bcc: #### Sending Email With Name Sometimes you wish to show the name of the person instead of just their email address when they receive the email. The trick to doing that is -to format the email address in the format `"Name "`. +to format the email address in the format `"Full Name "`. ```ruby def welcome_email(user) @@ -320,7 +320,7 @@ This will render the template 'another_template.html.erb' for the HTML part and Just like controller views, you can also have mailer layouts. The layout name needs to be the same as your mailer, such as `user_mailer.html.erb` and `user_mailer.text.erb` to be automatically recognized by your mailer as a layout. -In order to use a different file just use: +In order to use a different file, call `layout` in your mailer: ```ruby class UserMailer < ActionMailer::Base @@ -343,7 +343,7 @@ class UserMailer < ActionMailer::Base end ``` -Will render the HTML part using the `my_layout.html.erb` file and the text part with the usual `user_mailer.text.erb` file if it exists. +Will render the HTML template using the `my_layout.html.erb` file and the text template with the usual `user_mailer.text.erb` file if it exists. ### Generating URLs in Action Mailer Views @@ -547,7 +547,7 @@ config.action_mailer.default_options = {from: 'no-replay@example.org'} ### Action Mailer Configuration for GMail -As Action Mailer now uses the Mail gem, this becomes as simple as adding to your `config/environments/$RAILS_ENV.rb` file: +As Action Mailer uses the Mail gem, this becomes as simple as adding to your `config/environments/$RAILS_ENV.rb` file: ```ruby config.action_mailer.delivery_method = :smtp @@ -564,7 +564,7 @@ config.action_mailer.smtp_settings = { Mailer Testing -------------- -You can find detailed instructions on how to test your mailers in our +You can find detailed instructions on how to test your mailers in the [testing guide](testing.html#testing-your-mailers). Intercepting Emails From 919c86d2d5e7b74b96305c0bfb0482bbe61d99f2 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Tue, 2 Apr 2013 19:15:19 -0500 Subject: [PATCH 09/49] mark relation mutator as :nodoc: [ci skip] --- activerecord/lib/active_record/relation/query_methods.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 257221174b..7a9225da53 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -34,7 +34,6 @@ module ActiveRecord # # User.where.not(name: "Jon", role: "admin") # # SELECT * FROM users WHERE name != 'Jon' AND role != 'admin' - # def not(opts, *rest) where_value = @scope.send(:build_where, opts, rest).map do |rel| case rel @@ -353,7 +352,7 @@ module ActiveRecord spawn.unscope!(*args) end - def unscope!(*args) + def unscope!(*args) # :nodoc: args.flatten! args.each do |scope| From 8917a5b949856f8ef44d03d98470614c8cf8bbee Mon Sep 17 00:00:00 2001 From: Oliver Jakubiec Date: Tue, 2 Apr 2013 18:45:19 -0700 Subject: [PATCH 10/49] Added a section on Rails Controller naming conventions. --- guides/source/action_controller_overview.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md index 55aab1ef93..7c88e48fa9 100644 --- a/guides/source/action_controller_overview.md +++ b/guides/source/action_controller_overview.md @@ -27,6 +27,16 @@ A controller can thus be thought of as a middle man between models and views. It NOTE: For more details on the routing process, see [Rails Routing from the Outside In](routing.html). +Controller Naming Convention +---------------------------- + +The naming convention of controllers in Rails favors pluralization of the last word in the controller's name, although it is not strictly required (e.g. `ApplicationController`). For example, `ClientsController` is preferable to `ClientController`, `SiteAdminsController` is preferable to `SiteAdminController` or `SitesAdminsController`, and so on. + +Following this convention will allow you to use default route generators (e.g. `resources`, etc) without needing to qualify each `:path` or `:controller`, and keeps URL and path helpers' usage consistent throughout your applciation. See [Layouts & Rendering Guide](layouts_and_rendering.html) for more details. + +NOTE: Controller naming convention differs from the naming convention of Models, which prefer a singular naming convention. + + Methods and Actions ------------------- @@ -788,7 +798,7 @@ Rails comes with two built-in HTTP authentication mechanisms: HTTP basic authentication is an authentication scheme that is supported by the majority of browsers and other HTTP clients. As an example, consider an administration section which will only be available by entering a username and a password into the browser's HTTP basic dialog window. Using the built-in authentication is quite easy and only requires you to use one method, `http_basic_authenticate_with`. ```ruby -class AdminController < ApplicationController +class AdminsController < ApplicationController http_basic_authenticate_with name: "humbaba", password: "5baa61e4" end ``` @@ -800,7 +810,7 @@ With this in place, you can create namespaced controllers that inherit from `Adm HTTP digest authentication is superior to the basic authentication as it does not require the client to send an unencrypted password over the network (though HTTP basic authentication is safe over HTTPS). Using digest authentication with Rails is quite easy and only requires using one method, `authenticate_or_request_with_http_digest`. ```ruby -class AdminController < ApplicationController +class AdminsController < ApplicationController USERS = { "lifo" => "world" } before_action :authenticate From dc1347be2cfa99190ee462629b6490a71b4ce6a5 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Wed, 3 Apr 2013 12:15:11 +0200 Subject: [PATCH 11/49] adjust config.ru tempalte used in the rails on rack guide --- guides/source/rails_on_rack.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/guides/source/rails_on_rack.md b/guides/source/rails_on_rack.md index d8477d89e3..1bf34bf3cd 100644 --- a/guides/source/rails_on_rack.md +++ b/guides/source/rails_on_rack.md @@ -28,7 +28,10 @@ Rails on Rack ### Rails Application's Rack Object -`ApplicationName::Application` is the primary Rack application object of a Rails application. Any Rack compliant web server should be using `ApplicationName::Application` object to serve a Rails application. +`ApplicationName::Application` is the primary Rack application object of a Rails +application. Any Rack compliant web server should be using +`ApplicationName::Application` object to serve a Rails +application. `Rails.application` refers to the same application object. ### `rails server` @@ -79,11 +82,11 @@ To use `rackup` instead of Rails' `rails server`, you can put the following insi ```ruby # Rails.root/config.ru -require "config/environment" +require ::File.expand_path('../config/environment', __FILE__) use Rack::Debugger use Rack::ContentLength -run ApplicationName::Application +run Rails.application ``` And start the server: @@ -324,7 +327,7 @@ config.middleware.clear ```ruby # config.ru use MyOwnStackFromScratch -run ApplicationName::Application +run Rails.application ``` Resources From 3a90e81ee25a9ef56cec4af896f0d6cddc2ade41 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Wed, 3 Apr 2013 12:28:01 +0200 Subject: [PATCH 12/49] remove broken links from reference section in debugging guide. --- guides/source/debugging_rails_applications.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md index 31f96372ec..df7b113eb1 100644 --- a/guides/source/debugging_rails_applications.md +++ b/guides/source/debugging_rails_applications.md @@ -666,10 +666,7 @@ References * [ruby-debug Homepage](http://bashdb.sourceforge.net/ruby-debug/home-page.html) * [debugger Homepage](https://github.com/cldwalker/debugger) * [Article: Debugging a Rails application with ruby-debug](http://www.sitepoint.com/debug-rails-app-ruby-debug/) -* [ruby-debug Basics screencast](http://brian.maybeyoureinsane.net/blog/2007/05/07/ruby-debug-basics-screencast/) * [Ryan Bates' debugging ruby (revised) screencast](http://railscasts.com/episodes/54-debugging-ruby-revised) * [Ryan Bates' stack trace screencast](http://railscasts.com/episodes/24-the-stack-trace) * [Ryan Bates' logger screencast](http://railscasts.com/episodes/56-the-logger) * [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) From ab547e7b4368588719396a6f6b0528681c3a6cd4 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Wed, 3 Apr 2013 13:18:20 +0200 Subject: [PATCH 13/49] remove trailing whitespace from AR Basics guide --- guides/source/active_record_basics.md | 188 +++++++++++++------------- 1 file changed, 94 insertions(+), 94 deletions(-) diff --git a/guides/source/active_record_basics.md b/guides/source/active_record_basics.md index 69d7333e6f..f5afa77c42 100644 --- a/guides/source/active_record_basics.md +++ b/guides/source/active_record_basics.md @@ -1,14 +1,14 @@ Active Record Basics ==================== - + This guide is an introduction to Active Record. After reading this guide, you will know: -* What Object Relational Mapping and Active Record are and how they are used in +* What Object Relational Mapping and Active Record are and how they are used in Rails. * How Active Record fits into the Model-View-Controller paradigm. -* How to use Active Record models to manipulate data stored in a relational +* How to use Active Record models to manipulate data stored in a relational database. * Active Record schema naming conventions. * The concepts of database migrations, validations and callbacks. @@ -18,33 +18,33 @@ After reading this guide, you will know: What is Active Record? ---------------------- -Active Record is the M in [MVC](getting_started.html#the-mvc-architecture) - the -model - which is the layer of the system responsible for representing business -data and logic. Active Record facilitates the creation and use of business -objects whose data requires persistent storage to a database. It is an -implementation of the Active Record pattern which itself is a description of an +Active Record is the M in [MVC](getting_started.html#the-mvc-architecture) - the +model - which is the layer of the system responsible for representing business +data and logic. Active Record facilitates the creation and use of business +objects whose data requires persistent storage to a database. It is an +implementation of the Active Record pattern which itself is a description of an Object Relational Mapping system. ### The Active Record Pattern -Active Record was described by Martin Fowler in his book _Patterns of Enterprise -Application Architecture_. In Active Record, objects carry both persistent data -and behavior which operates on that data. Active Record takes the opinion that -ensuring data access logic is part of the object will educate users of that +Active Record was described by Martin Fowler in his book _Patterns of Enterprise +Application Architecture_. In Active Record, objects carry both persistent data +and behavior which operates on that data. Active Record takes the opinion that +ensuring data access logic is part of the object will educate users of that object on how to write to and read from the database. ### Object Relational Mapping -Object-Relational Mapping, commonly referred to as its abbreviation ORM, is -a technique that connects the rich objects of an application to tables in -a relational database management system. Using ORM, the properties and -relationships of the objects in an application can be easily stored and -retrieved from a database without writing SQL statements directly and with less +Object-Relational Mapping, commonly referred to as its abbreviation ORM, is +a technique that connects the rich objects of an application to tables in +a relational database management system. Using ORM, the properties and +relationships of the objects in an application can be easily stored and +retrieved from a database without writing SQL statements directly and with less overall database access code. ### Active Record as an ORM Framework -Active Record gives us several mechanisms, the most important being the ability +Active Record gives us several mechanisms, the most important being the ability to: * Represent models and their data @@ -56,29 +56,29 @@ to: Convention over Configuration in Active Record ---------------------------------------------- -When writing applications using other programming languages or frameworks, it -may be necessary to write a lot of configuration code. This is particularly true -for ORM frameworks in general. However, if you follow the conventions adopted by -Rails, you'll need to write very little configuration (in some case no -configuration at all) when creating Active Record models. The idea is that if -you configure your applications in the very same way most of the times then this -should be the default way. In this cases, explicit configuration would be needed +When writing applications using other programming languages or frameworks, it +may be necessary to write a lot of configuration code. This is particularly true +for ORM frameworks in general. However, if you follow the conventions adopted by +Rails, you'll need to write very little configuration (in some case no +configuration at all) when creating Active Record models. The idea is that if +you configure your applications in the very same way most of the times then this +should be the default way. In this cases, explicit configuration would be needed only in those cases where you can't follow the conventions for any reason. ### Naming Conventions -By default, Active Record uses some naming conventions to find out how the -mapping between models and database tables should be created. Rails will -pluralize your class names to find the respective database table. So, for -a class `Book`, you should have a database table called **books**. The Rails -pluralization mechanisms are very powerful, being capable to pluralize (and -singularize) both regular and irregular words. When using class names composed -of two or more words, the model class name should follow the Ruby conventions, -using the CamelCase form, while the table name must contain the words separated +By default, Active Record uses some naming conventions to find out how the +mapping between models and database tables should be created. Rails will +pluralize your class names to find the respective database table. So, for +a class `Book`, you should have a database table called **books**. The Rails +pluralization mechanisms are very powerful, being capable to pluralize (and +singularize) both regular and irregular words. When using class names composed +of two or more words, the model class name should follow the Ruby conventions, +using the CamelCase form, while the table name must contain the words separated by underscores. Examples: * Database Table - Plural with underscores separating words (e.g., `book_clubs`) -* Model Class - Singular with the first letter of each word capitalized (e.g., +* Model Class - Singular with the first letter of each word capitalized (e.g., `BookClub`) | Model / Class | Table / Schema | @@ -92,33 +92,33 @@ by underscores. Examples: ### Schema Conventions -Active Record uses naming conventions for the columns in database tables, +Active Record uses naming conventions for the columns in database tables, depending on the purpose of these columns. -* **Foreign keys** - These fields should be named following the pattern - `singularized_table_name_id` (e.g., `item_id`, `order_id`). These are the - fields that Active Record will look for when you create associations between +* **Foreign keys** - These fields should be named following the pattern + `singularized_table_name_id` (e.g., `item_id`, `order_id`). These are the + fields that Active Record will look for when you create associations between your models. -* **Primary keys** - By default, Active Record will use an integer column named - `id` as the table's primary key. When using [Rails - Migrations](migrations.html) to create your tables, this column will be +* **Primary keys** - By default, Active Record will use an integer column named + `id` as the table's primary key. When using [Rails + Migrations](migrations.html) to create your tables, this column will be automatically created. -There are also some optional column names that will create additional features +There are also some optional column names that will create additional features to Active Record instances: -* `created_at` - Automatically gets set to the current date and time when the +* `created_at` - Automatically gets set to the current date and time when the record is first created. -* `updated_at` - Automatically gets set to the current date and time whenever +* `updated_at` - Automatically gets set to the current date and time whenever the record is updated. -* `lock_version` - Adds [optimistic - locking](http://api.rubyonrails.org/classes/ActiveRecord/Locking.html) to +* `lock_version` - Adds [optimistic + locking](http://api.rubyonrails.org/classes/ActiveRecord/Locking.html) to a model. -* `type` - Specifies that the model uses [Single Table +* `type` - Specifies that the model uses [Single Table Inheritance](http://api.rubyonrails.org/classes/ActiveRecord/Base.html) -* `(table_name)_count` - Used to cache the number of belonging objects on - associations. For example, a `comments_count` column in a `Post` class that - has many instances of `Comment` will cache the number of existent comments +* `(table_name)_count` - Used to cache the number of belonging objects on + associations. For example, a `comments_count` column in a `Post` class that + has many instances of `Comment` will cache the number of existent comments for each post. NOTE: While these column names are optional, they are in fact reserved by Active Record. Steer clear of reserved keywords unless you want the extra functionality. For example, `type` is a reserved keyword used to designate a table using Single Table Inheritance (STI). If you are not using STI, try an analogous keyword like "context", that may still accurately describe the data you are modeling. @@ -126,7 +126,7 @@ NOTE: While these column names are optional, they are in fact reserved by Active Creating Active Record Models ----------------------------- -It is very easy to create Active Record models. All you have to do is to +It is very easy to create Active Record models. All you have to do is to subclass the `ActiveRecord::Base` class and you're good to go: ```ruby @@ -134,9 +134,9 @@ class Product < ActiveRecord::Base end ``` -This will create a `Product` model, mapped to a `products` table at the -database. By doing this you'll also have the ability to map the columns of each -row in that table with the attributes of the instances of your model. Suppose +This will create a `Product` model, mapped to a `products` table at the +database. By doing this you'll also have the ability to map the columns of each +row in that table with the attributes of the instances of your model. Suppose that the `products` table was created using an SQL sentence like: ```sql @@ -147,7 +147,7 @@ CREATE TABLE products ( ); ``` -Following the table schema above, you would be able to write code like the +Following the table schema above, you would be able to write code like the following: ```ruby @@ -159,11 +159,11 @@ puts p.name # "Some Book" Overriding the Naming Conventions --------------------------------- -What if you need to follow a different naming convention or need to use your -Rails application with a legacy database? No problem, you can easily override +What if you need to follow a different naming convention or need to use your +Rails application with a legacy database? No problem, you can easily override the default conventions. -You can use the `ActiveRecord::Base.table_name=` method to specify the table +You can use the `ActiveRecord::Base.table_name=` method to specify the table name that should be used: ```ruby @@ -172,8 +172,8 @@ class Product < ActiveRecord::Base end ``` -If you do so, you will have to define manually the class name that is hosting -the fixtures (class_name.yml) using the `set_fixture_class` method in your test +If you do so, you will have to define manually the class name that is hosting +the fixtures (class_name.yml) using the `set_fixture_class` method in your test definition: ```ruby @@ -184,7 +184,7 @@ class FunnyJoke < ActiveSupport::TestCase end ``` -It's also possible to override the column that should be used as the table's +It's also possible to override the column that should be used as the table's primary key using the `ActiveRecord::Base.set_primary_key` method: ```ruby @@ -196,17 +196,17 @@ end CRUD: Reading and Writing Data ------------------------------ -CRUD is an acronym for the four verbs we use to operate on data: **C**reate, -**R**ead, **U**pdate and **D**elete. Active Record automatically creates methods +CRUD is an acronym for the four verbs we use to operate on data: **C**reate, +**R**ead, **U**pdate and **D**elete. Active Record automatically creates methods to allow an application to read and manipulate data stored within its tables. ### Create -Active Record objects can be created from a hash, a block or have their -attributes manually set after creation. The `new` method will return a new +Active Record objects can be created from a hash, a block or have their +attributes manually set after creation. The `new` method will return a new object while `create` will return the object and save it to the database. -For example, given a model `User` with attributes of `name` and `occupation`, +For example, given a model `User` with attributes of `name` and `occupation`, the `create` method call will create and save a new record into the database: ```ruby @@ -223,7 +223,7 @@ user.occupation = "Code Artist" A call to `user.save` will commit the record to the database. -Finally, if a block is provided, both `create` and `new` will yield the new +Finally, if a block is provided, both `create` and `new` will yield the new object to that block for initialization: ```ruby @@ -235,7 +235,7 @@ end ### Read -Active Record provides a rich API for accessing data within a database. Below +Active Record provides a rich API for accessing data within a database. Below are a few examples of different data access methods provided by Active Record. ```ruby @@ -258,12 +258,12 @@ david = User.find_by_name('David') users = User.where(name: 'David', occupation: 'Code Artist').order('created_at DESC') ``` -You can learn more about querying an Active Record model in the [Active Record +You can learn more about querying an Active Record model in the [Active Record Query Interface](active_record_querying.html) guide. ### Update -Once an Active Record object has been retrieved, its attributes can be modified +Once an Active Record object has been retrieved, its attributes can be modified and it can be saved to the database. ```ruby @@ -272,7 +272,7 @@ user.name = 'Dave' user.save ``` -A shorthand for this is to use a hash mapping attribute names to the desired +A shorthand for this is to use a hash mapping attribute names to the desired value, like so: ```ruby @@ -280,8 +280,8 @@ user = User.find_by_name('David') user.update(name: 'Dave') ``` -This is most useful when updating several attributes at once. If, on the other -hand, you'd like to update several records in bulk, you may find the +This is most useful when updating several attributes at once. If, on the other +hand, you'd like to update several records in bulk, you may find the `update_all` class method useful: ```ruby @@ -290,7 +290,7 @@ User.update_all "max_login_attempts = 3, must_change_password = 'true'" ### Delete -Likewise, once retrieved an Active Record object can be destroyed which removes +Likewise, once retrieved an Active Record object can be destroyed which removes it from the database. ```ruby @@ -301,17 +301,17 @@ user.destroy Validations ----------- -Active Record allows you to validate the state of a model before it gets written -into the database. There are several methods that you can use to check your -models and validate that an attribute value is not empty, is unique and not +Active Record allows you to validate the state of a model before it gets written +into the database. There are several methods that you can use to check your +models and validate that an attribute value is not empty, is unique and not already in the database, follows a specific format and many more. -Validation is a very important issue to consider when persisting to database, so -the methods `create`, `save` and `update` take it into account when -running: they return `false` when validation fails and they didn't actually -perform any operation on database. All of these have a bang counterpart (that -is, `create!`, `save!` and `update!`), which are stricter in that -they raise the exception `ActiveRecord::RecordInvalid` if validation fails. +Validation is a very important issue to consider when persisting to database, so +the methods `create`, `save` and `update` take it into account when +running: they return `false` when validation fails and they didn't actually +perform any operation on database. All of these have a bang counterpart (that +is, `create!`, `save!` and `update!`), which are stricter in that +they raise the exception `ActiveRecord::RecordInvalid` if validation fails. A quick example to illustrate: ```ruby @@ -323,24 +323,24 @@ User.create # => false User.create! # => ActiveRecord::RecordInvalid: Validation failed: Name can't be blank ``` -You can learn more about validations in the [Active Record Validations +You can learn more about validations in the [Active Record Validations guide](active_record_validations.html). Callbacks --------- -Active Record callbacks allow you to attach code to certain events in the -life-cycle of your models. This enables you to add behavior to your models by -transparently executing code when those events occur, like when you create a new -record, update it, destroy it and so on. You can learn more about callbacks in +Active Record callbacks allow you to attach code to certain events in the +life-cycle of your models. This enables you to add behavior to your models by +transparently executing code when those events occur, like when you create a new +record, update it, destroy it and so on. You can learn more about callbacks in the [Active Record Callbacks guide](active_record_callbacks.html). Migrations ---------- -Rails provides a domain-specific language for managing a database schema called -migrations. Migrations are stored in files which are executed against any -database that Active Record support using `rake`. Here's a migration that +Rails provides a domain-specific language for managing a database schema called +migrations. Migrations are stored in files which are executed against any +database that Active Record support using `rake`. Here's a migration that creates a table: ```ruby @@ -361,10 +361,10 @@ class CreatePublications < ActiveRecord::Migration end ``` -Rails keeps track of which files have been committed to the database and +Rails keeps track of which files have been committed to the database and provides rollback features. To actually create the table, you'd run `rake db:migrate` and to roll it back, `rake db:rollback`. -Note that the above code is database-agnostic: it will run in MySQL, postgresql, -Oracle and others. You can learn more about migrations in the [Active Record +Note that the above code is database-agnostic: it will run in MySQL, postgresql, +Oracle and others. You can learn more about migrations in the [Active Record Migrations guide](migrations.html) From d131c9a4f6f49b8c7378fedd651d81f423dec193 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Wed, 3 Apr 2013 13:19:20 +0200 Subject: [PATCH 14/49] link the Active Record pattern to the EAA Catalog --- guides/source/active_record_basics.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/guides/source/active_record_basics.md b/guides/source/active_record_basics.md index f5afa77c42..7a5e1bf4eb 100644 --- a/guides/source/active_record_basics.md +++ b/guides/source/active_record_basics.md @@ -27,10 +27,11 @@ Object Relational Mapping system. ### The Active Record Pattern -Active Record was described by Martin Fowler in his book _Patterns of Enterprise -Application Architecture_. In Active Record, objects carry both persistent data -and behavior which operates on that data. Active Record takes the opinion that -ensuring data access logic is part of the object will educate users of that +[Active Record was described by Martin Fowler](http://www.martinfowler.com/eaaCatalog/activeRecord.html) +in his book _Patterns of Enterprise Application Architecture_. In +Active Record, objects carry both persistent data and behavior which +operates on that data. Active Record takes the opinion that ensuring +data access logic is part of the object will educate users of that object on how to write to and read from the database. ### Object Relational Mapping From 7c69945c765e7704edc01b3910df28a4792da859 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Wed, 3 Apr 2013 13:36:30 +0200 Subject: [PATCH 15/49] add `(association)`_type to schema convetions in AR basics guide. --- guides/source/active_record_basics.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guides/source/active_record_basics.md b/guides/source/active_record_basics.md index 7a5e1bf4eb..91d3ed4da8 100644 --- a/guides/source/active_record_basics.md +++ b/guides/source/active_record_basics.md @@ -117,6 +117,8 @@ to Active Record instances: a model. * `type` - Specifies that the model uses [Single Table Inheritance](http://api.rubyonrails.org/classes/ActiveRecord/Base.html) +* `(association_name)_type` - Stores the type for + [polymorphic associations](association_basics.html#polymorphic-associations). * `(table_name)_count` - Used to cache the number of belonging objects on associations. For example, a `comments_count` column in a `Post` class that has many instances of `Comment` will cache the number of existent comments From a3bb1385b07a5816d4882b32a84787ee1ab78746 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Wed, 3 Apr 2013 14:08:48 +0200 Subject: [PATCH 16/49] fix formatting typo, + should be ` --- guides/source/configuring.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 9ea493325d..a0ab707b51 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -268,7 +268,7 @@ config.middleware.delete "Rack::MethodOverride" * `config.active_record.lock_optimistically` controls whether Active Record will use optimistic locking and is true by default. -* +config.active_record.cache_timestamp_format+ controls the format of the timestamp value in the cache key. Default is +:number+. +* `config.active_record.cache_timestamp_format` controls the format of the timestamp value in the cache key. Default is `:number`. The MySQL adapter adds one additional configuration option: From bf8f9c8ee28af808902c8e3da73ccb8d8fbb4cf1 Mon Sep 17 00:00:00 2001 From: Jonathan Roes Date: Wed, 3 Apr 2013 10:55:46 -0300 Subject: [PATCH 17/49] Typos/grammar fixes --- guides/source/action_controller_overview.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md index f197591592..db91425c76 100644 --- a/guides/source/action_controller_overview.md +++ b/guides/source/action_controller_overview.md @@ -30,11 +30,11 @@ NOTE: For more details on the routing process, see [Rails Routing from the Outsi Controller Naming Convention ---------------------------- -The naming convention of controllers in Rails favors pluralization of the last word in the controller's name, although it is not strictly required (e.g. `ApplicationController`). For example, `ClientsController` is preferable to `ClientController`, `SiteAdminsController` is preferable to `SiteAdminController` or `SitesAdminsController`, and so on. +The naming convention of controllers in Rails favors pluralization of the last word in the controller's name, although it is not strictly required (e.g. `ApplicationController`). For example, `ClientsController` is preferable to `ClientController`, `SiteAdminsController` is preferable to `SiteAdminController` or `SitesAdminsController`, and so on. -Following this convention will allow you to use default route generators (e.g. `resources`, etc) without needing to qualify each `:path` or `:controller`, and keeps URL and path helpers' usage consistent throughout your applciation. See [Layouts & Rendering Guide](layouts_and_rendering.html) for more details. +Following this convention will allow you to use the default route generators (e.g. `resources`, etc) without needing to qualify each `:path` or `:controller`, and keeps URL and path helpers' usage consistent throughout your application. See [Layouts & Rendering Guide](layouts_and_rendering.html) for more details. -NOTE: Controller naming convention differs from the naming convention of Models, which prefer a singular naming convention. +NOTE: The controller naming convention differs from the naming convention of models, which expected to be named in singular form. Methods and Actions From a4bd64ffeda0ffe2839030044eca762835be7901 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Wed, 3 Apr 2013 20:44:35 +0530 Subject: [PATCH 18/49] Changed rspec/model directory example to spec/models --- guides/source/command_line.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/guides/source/command_line.md b/guides/source/command_line.md index 4711186522..7b7f5963fd 100644 --- a/guides/source/command_line.md +++ b/guides/source/command_line.md @@ -445,12 +445,12 @@ NOTE. When using specific annotations and custom annotations, the annotation nam By default, `rake notes` will look in the `app`, `config`, `lib`, `bin` and `test` directories. If you would like to search other directories, you can provide them as a comma separated list in an environment variable `SOURCE_ANNOTATION_DIRECTORIES`. ```bash -$ export SOURCE_ANNOTATION_DIRECTORIES='rspec,vendor' +$ export SOURCE_ANNOTATION_DIRECTORIES='spec,vendor' $ rake notes (in /home/foobar/commandsapp) app/models/user.rb: * [ 35] [FIXME] User should have a subscription at this point -rspec/model/user_spec.rb: +spec/models/user_spec.rb: * [122] [TODO] Verify the user that has a subscription works ``` From 8e17908d670137c9c298a3e47a01aa5307513bf3 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Wed, 3 Apr 2013 22:47:31 +0530 Subject: [PATCH 19/49] Fixed Typo --- guides/source/rails_on_rack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/rails_on_rack.md b/guides/source/rails_on_rack.md index 1bf34bf3cd..e6fdedb911 100644 --- a/guides/source/rails_on_rack.md +++ b/guides/source/rails_on_rack.md @@ -104,7 +104,7 @@ $ rackup --help Action Dispatcher Middleware Stack ---------------------------------- -Many of Action Dispatchers's internal components are implemented as Rack middlewares. `Rails::Application` uses `ActionDispatch::MiddlewareStack` to combine various internal and external middlewares to form a complete Rails Rack application. +Many of Action Dispatcher's internal components are implemented as Rack middlewares. `Rails::Application` uses `ActionDispatch::MiddlewareStack` to combine various internal and external middlewares to form a complete Rails Rack application. NOTE: `ActionDispatch::MiddlewareStack` is Rails equivalent of `Rack::Builder`, but built for better flexibility and more features to meet Rails' requirements. From 64d8cdee312c85a99a373922d1bf99e0ca047def Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Wed, 3 Apr 2013 16:32:33 -0500 Subject: [PATCH 20/49] fix broken format in ActionView::Helpers::NumberHelper [ci skip] --- .../lib/action_view/helpers/number_helper.rb | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb index 9e1be65b1a..fda7038a5d 100644 --- a/actionpack/lib/action_view/helpers/number_helper.rb +++ b/actionpack/lib/action_view/helpers/number_helper.rb @@ -28,6 +28,8 @@ module ActionView # Formats a +number+ into a US phone number (e.g., (555) # 123-9876). You can customize the format in the +options+ hash. # + # ==== Options + # # * :area_code - Adds parentheses around the area code. # * :delimiter - Specifies the delimiter to use # (defaults to "-"). @@ -38,6 +40,8 @@ module ActionView # * :raise - If true, raises +InvalidNumberError+ when # the argument is invalid. # + # ==== Examples + # # number_to_phone(5551234) # => 555-1234 # number_to_phone("5551234") # => 555-1234 # number_to_phone(1235551234) # => 123-555-1234 @@ -61,6 +65,8 @@ module ActionView # Formats a +number+ into a currency string (e.g., $13.65). You # can customize the format in the +options+ hash. # + # ==== Options + # # * :locale - Sets the locale to be used for formatting # (defaults to current locale). # * :precision - Sets the level of precision (defaults @@ -82,6 +88,8 @@ module ActionView # * :raise - If true, raises +InvalidNumberError+ when # the argument is invalid. # + # ==== Examples + # # number_to_currency(1234567890.50) # => $1,234,567,890.50 # number_to_currency(1234567890.506) # => $1,234,567,890.51 # number_to_currency(1234567890.506, precision: 3) # => $1,234,567,890.506 @@ -108,6 +116,7 @@ module ActionView # Formats a +number+ as a percentage string (e.g., 65%). You can # customize the format in the +options+ hash. # + # ==== Options # # * :locale - Sets the locale to be used for formatting # (defaults to current locale). @@ -128,6 +137,8 @@ module ActionView # * :raise - If true, raises +InvalidNumberError+ when # the argument is invalid. # + # ==== Examples + # # number_to_percentage(100) # => 100.000% # number_to_percentage("98") # => 98.000% # number_to_percentage(100, precision: 0) # => 100% @@ -151,6 +162,8 @@ module ActionView # (e.g., 12,324). You can customize the format in the +options+ # hash. # + # ==== Options + # # * :locale - Sets the locale to be used for formatting # (defaults to current locale). # * :delimiter - Sets the thousands delimiter (defaults @@ -160,6 +173,8 @@ module ActionView # * :raise - If true, raises +InvalidNumberError+ when # the argument is invalid. # + # ==== Examples + # # number_with_delimiter(12345678) # => 12,345,678 # number_with_delimiter("123456") # => 123,456 # number_with_delimiter(12345678.05) # => 12,345,678.05 @@ -185,6 +200,8 @@ module ActionView # +:significant+ is +false+, and 5 if +:significant+ is +true+). # You can customize the format in the +options+ hash. # + # ==== Options + # # * :locale - Sets the locale to be used for formatting # (defaults to current locale). # * :precision - Sets the precision of the number @@ -202,6 +219,8 @@ module ActionView # * :raise - If true, raises +InvalidNumberError+ when # the argument is invalid. # + # ==== Examples + # # number_with_precision(111.2345) # => 111.235 # number_with_precision(111.2345, precision: 2) # => 111.23 # number_with_precision(13, precision: 5) # => 13.00000 @@ -233,6 +252,8 @@ module ActionView # See number_to_human if you want to pretty-print a # generic number. # + # ==== Options + # # * :locale - Sets the locale to be used for formatting # (defaults to current locale). # * :precision - Sets the precision of the number @@ -252,6 +273,8 @@ module ActionView # * :raise - If true, raises +InvalidNumberError+ when # the argument is invalid. # + # ==== Examples + # # number_to_human_size(123) # => 123 Bytes # number_to_human_size(1234) # => 1.21 KB # number_to_human_size(12345) # => 12.1 KB @@ -324,6 +347,8 @@ module ActionView # * :raise - If true, raises +InvalidNumberError+ when # the argument is invalid. # + # ==== Examples + # # number_to_human(123) # => "123" # number_to_human(1234) # => "1.23 Thousand" # number_to_human(12345) # => "12.3 Thousand" From 5282a8243ad578e3b36cce8ed826563a4f6a6c3e Mon Sep 17 00:00:00 2001 From: Weston Platter Date: Wed, 3 Apr 2013 23:48:06 -0500 Subject: [PATCH 21/49] [layout/rendering guide] remove redundant wording --- guides/source/layouts_and_rendering.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md index a3b3472701..2fa6d805c9 100644 --- a/guides/source/layouts_and_rendering.md +++ b/guides/source/layouts_and_rendering.md @@ -1,9 +1,7 @@ Layouts and Rendering in Rails ============================== -This guide covers the basic layout features of Action Controller and Action View. By referring to this guide, you will be able to: - -After reading this guide, you will know: +This guide covers the basic layout features of Action Controller and Action View. After reading this guide, you will know: * How to use the various rendering methods built into Rails. * How to create layouts with multiple content sections. From af8a788ab7f18a23d46d9b8fb5ceceef2c527045 Mon Sep 17 00:00:00 2001 From: Weston Platter Date: Thu, 4 Apr 2013 00:11:21 -0500 Subject: [PATCH 22/49] [layout/rendering guide] move sentence to new line to follow convention in other guides. --- guides/source/layouts_and_rendering.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md index 2fa6d805c9..80d0f4eef2 100644 --- a/guides/source/layouts_and_rendering.md +++ b/guides/source/layouts_and_rendering.md @@ -1,7 +1,9 @@ Layouts and Rendering in Rails ============================== -This guide covers the basic layout features of Action Controller and Action View. After reading this guide, you will know: +This guide covers the basic layout features of Action Controller and Action View. + +After reading this guide, you will know: * How to use the various rendering methods built into Rails. * How to create layouts with multiple content sections. From c918298c8e5096b58dfcfbeb2a8a90c17ab4df3e Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Thu, 4 Apr 2013 13:22:12 +0200 Subject: [PATCH 23/49] describe Action Mailer I18n subject lookup --- guides/source/i18n.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/guides/source/i18n.md b/guides/source/i18n.md index 5304ca4285..d187d3a03a 100644 --- a/guides/source/i18n.md +++ b/guides/source/i18n.md @@ -837,6 +837,28 @@ en: 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'`. +### Translations for Action Mailer E-Mail Subjects + +If you don't pass a subject to the `mail` method, Action Mailer will try to find +it in your translations. The performed lookup will use the pattern +`..subject` to construct the key. + +```ruby +# user_mailer.rb +class UserMailer < ActionMailer::Base + def welcome(user) + #... + end +end +``` + +```yaml +en: + user_mailer: + welcome: + subject: "Welcome to Rails Guides!" +``` + ### 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. From 567ea4ba29074079a05ba327c2d78e4a68eb3882 Mon Sep 17 00:00:00 2001 From: Jonathan Roes Date: Thu, 4 Apr 2013 14:14:48 -0300 Subject: [PATCH 24/49] Basic Layouts overview w/ link to guide --- guides/source/action_view_overview.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/guides/source/action_view_overview.md b/guides/source/action_view_overview.md index 3b5963efc2..dea1ddef71 100644 --- a/guides/source/action_view_overview.md +++ b/guides/source/action_view_overview.md @@ -172,7 +172,7 @@ That code will pull in the partial from `app/views/shared/_menu.html.erb`. #### Using Partials to simplify Views -One way to use partials is to treat them as the equivalent of subroutines: as a way to move details out of a view so that you can grasp what's going on more easily. For example, you might have a view that looked like this: +One way to use partials is to treat them as the equivalent of subroutines; a way to move details out of a view so that you can grasp what's going on more easily. For example, you might have a view that looks like this: ```html+erb <%= render "shared/ad_banner" %> @@ -269,12 +269,7 @@ Rails will render the `_product_ruler` partial (with no data passed to it) betwe ### Layouts -TODO... - -Using Templates, Partials and Layouts "The Rails Way" --------------------------------------------------------- - -TODO... +Layouts can be used to render a common view template around the results of Rails controller actions. Typically, every Rails has a couple of overall layouts that most pages are rendered within. For example, a site might have a layout for a logged in user, and a layout for the marketing or sales side of the site. The logged in user layout might include top-level navigation that should be present across many controller actions. The sales layout for a SaaS app might include top-level navigation for things like "Pricing" and "Contact Us." You would expect each layout to have a different look and feel. You can read more details about Layouts in the [Layouts and Rendering in Rails](layouts_and_rendering.html) guide. Partial Layouts --------------- From 08d651693654f89fe60b9ad3e7eca568a3081e64 Mon Sep 17 00:00:00 2001 From: Jonathan Roes Date: Thu, 4 Apr 2013 14:18:58 -0300 Subject: [PATCH 25/49] Add Action View Overview to guides listing. --- guides/source/documents.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/guides/source/documents.yaml b/guides/source/documents.yaml index c73bbeb90d..043f34fa25 100644 --- a/guides/source/documents.yaml +++ b/guides/source/documents.yaml @@ -35,6 +35,10 @@ - name: Views documents: + - + name: Action View Overview + url: action_view_overview.html + description: This guide provides an introduction to Action View and introduces a few of the more common view helpers. - name: Layouts and Rendering in Rails url: layouts_and_rendering.html From edeb98c2745cbf29725eca87332cefb4f273986a Mon Sep 17 00:00:00 2001 From: Jonathan Roes Date: Thu, 4 Apr 2013 14:36:22 -0300 Subject: [PATCH 26/49] Update Ryan Bigg's occupation and credentials. --- guides/source/credits.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/credits.html.erb b/guides/source/credits.html.erb index ff76fa2b85..d436deb832 100644 --- a/guides/source/credits.html.erb +++ b/guides/source/credits.html.erb @@ -28,7 +28,7 @@ Ruby on Rails Guides: Credits

Rails Guides Authors

<%= author('Ryan Bigg', 'radar', 'radar.png') do %> -Ryan Bigg works as a consultant at RubyX and has been working with Rails since 2006. He's co-authoring a book called Rails 3 in Action and he's written many gems which can be seen on his GitHub page and he also tweets prolifically as @ryanbigg. +Ryan Bigg works as the Community Manager at Spree Commerce and has been working with Rails since 2006. He's the author of Multi Tenancy With Rails and co-author of Rails 3 in Action. He's written many gems which can be seen on his GitHub page and he also tweets prolifically as @ryanbigg. <% end %> <%= author('Oscar Del Ben', 'oscardelben', 'oscardelben.jpg') do %> From 2a16e159ab718374582183a857f5bcb6f1c78b0b Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Thu, 4 Apr 2013 16:46:06 -0500 Subject: [PATCH 27/49] mark ActionView::Helpers::Tags as :nodoc: [ci skip] --- actionpack/lib/action_view/helpers/tags/base.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/check_box.rb | 2 +- actionpack/lib/action_view/helpers/tags/checkable.rb | 4 ++-- .../lib/action_view/helpers/tags/collection_check_boxes.rb | 6 +++--- .../lib/action_view/helpers/tags/collection_helpers.rb | 6 +++--- .../action_view/helpers/tags/collection_radio_buttons.rb | 6 +++--- .../lib/action_view/helpers/tags/collection_select.rb | 2 +- actionpack/lib/action_view/helpers/tags/color_field.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/date_field.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/date_select.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/datetime_field.rb | 4 ++-- .../lib/action_view/helpers/tags/datetime_local_field.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/datetime_select.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/email_field.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/file_field.rb | 4 ++-- .../action_view/helpers/tags/grouped_collection_select.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/hidden_field.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/label.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/month_field.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/number_field.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/password_field.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/radio_button.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/range_field.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/search_field.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/select.rb | 5 ++--- actionpack/lib/action_view/helpers/tags/tel_field.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/text_area.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/text_field.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/time_field.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/time_select.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/time_zone_select.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/url_field.rb | 4 ++-- actionpack/lib/action_view/helpers/tags/week_field.rb | 4 ++-- 33 files changed, 67 insertions(+), 68 deletions(-) diff --git a/actionpack/lib/action_view/helpers/tags/base.rb b/actionpack/lib/action_view/helpers/tags/base.rb index aef1572290..7d1ca1f2b3 100644 --- a/actionpack/lib/action_view/helpers/tags/base.rb +++ b/actionpack/lib/action_view/helpers/tags/base.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class Base #:nodoc: + module Tags # :nodoc: + class Base # :nodoc: include Helpers::ActiveModelInstanceTag, Helpers::TagHelper, Helpers::FormTagHelper include FormOptionsHelper diff --git a/actionpack/lib/action_view/helpers/tags/check_box.rb b/actionpack/lib/action_view/helpers/tags/check_box.rb index e21cc07746..6d51f2629a 100644 --- a/actionpack/lib/action_view/helpers/tags/check_box.rb +++ b/actionpack/lib/action_view/helpers/tags/check_box.rb @@ -2,7 +2,7 @@ require 'action_view/helpers/tags/checkable' module ActionView module Helpers - module Tags + module Tags # :nodoc: class CheckBox < Base #:nodoc: include Checkable diff --git a/actionpack/lib/action_view/helpers/tags/checkable.rb b/actionpack/lib/action_view/helpers/tags/checkable.rb index b97c0c68d7..052e9df662 100644 --- a/actionpack/lib/action_view/helpers/tags/checkable.rb +++ b/actionpack/lib/action_view/helpers/tags/checkable.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - module Checkable + module Tags # :nodoc: + module Checkable # :nodoc: def input_checked?(object, options) if options.has_key?("checked") checked = options.delete "checked" diff --git a/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb b/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb index 9655008fe2..52006d856b 100644 --- a/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb +++ b/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb @@ -2,11 +2,11 @@ require 'action_view/helpers/tags/collection_helpers' module ActionView module Helpers - module Tags - class CollectionCheckBoxes < Base + module Tags # :nodoc: + class CollectionCheckBoxes < Base # :nodoc: include CollectionHelpers - class CheckBoxBuilder < Builder + class CheckBoxBuilder < Builder # :nodoc: def check_box(extra_html_options={}) html_options = extra_html_options.merge(@input_html_options) @template_object.check_box(@object_name, @method_name, html_options, @value, nil) diff --git a/actionpack/lib/action_view/helpers/tags/collection_helpers.rb b/actionpack/lib/action_view/helpers/tags/collection_helpers.rb index e92a318c73..cd12ddaf65 100644 --- a/actionpack/lib/action_view/helpers/tags/collection_helpers.rb +++ b/actionpack/lib/action_view/helpers/tags/collection_helpers.rb @@ -1,8 +1,8 @@ module ActionView module Helpers - module Tags - module CollectionHelpers - class Builder + module Tags # :nodoc: + module CollectionHelpers # :nodoc: + class Builder # :nodoc: attr_reader :object, :text, :value def initialize(template_object, object_name, method_name, object, diff --git a/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb b/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb index 893f4411e7..20be34c1f2 100644 --- a/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb +++ b/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb @@ -2,11 +2,11 @@ require 'action_view/helpers/tags/collection_helpers' module ActionView module Helpers - module Tags - class CollectionRadioButtons < Base + module Tags # :nodoc: + class CollectionRadioButtons < Base # :nodoc: include CollectionHelpers - class RadioButtonBuilder < Builder + class RadioButtonBuilder < Builder # :nodoc: def radio_button(extra_html_options={}) html_options = extra_html_options.merge(@input_html_options) @template_object.radio_button(@object_name, @method_name, @value, html_options) diff --git a/actionpack/lib/action_view/helpers/tags/collection_select.rb b/actionpack/lib/action_view/helpers/tags/collection_select.rb index ec78e6e5f9..6cb2b2e0d3 100644 --- a/actionpack/lib/action_view/helpers/tags/collection_select.rb +++ b/actionpack/lib/action_view/helpers/tags/collection_select.rb @@ -1,6 +1,6 @@ module ActionView module Helpers - module Tags + module Tags # :nodoc: class CollectionSelect < Base #:nodoc: def initialize(object_name, method_name, template_object, collection, value_method, text_method, options, html_options) @collection = collection diff --git a/actionpack/lib/action_view/helpers/tags/color_field.rb b/actionpack/lib/action_view/helpers/tags/color_field.rb index 6f08f8483a..d8fc797035 100644 --- a/actionpack/lib/action_view/helpers/tags/color_field.rb +++ b/actionpack/lib/action_view/helpers/tags/color_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class ColorField < TextField #:nodoc: + module Tags # :nodoc: + class ColorField < TextField # :nodoc: def render options = @options.stringify_keys options["value"] = @options.fetch("value") { validate_color_string(value(object)) } diff --git a/actionpack/lib/action_view/helpers/tags/date_field.rb b/actionpack/lib/action_view/helpers/tags/date_field.rb index 64c29dea3d..c22be0db29 100644 --- a/actionpack/lib/action_view/helpers/tags/date_field.rb +++ b/actionpack/lib/action_view/helpers/tags/date_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class DateField < DatetimeField #:nodoc: + module Tags # :nodoc: + class DateField < DatetimeField # :nodoc: private def format_date(value) diff --git a/actionpack/lib/action_view/helpers/tags/date_select.rb b/actionpack/lib/action_view/helpers/tags/date_select.rb index 734591394b..0c4ac40070 100644 --- a/actionpack/lib/action_view/helpers/tags/date_select.rb +++ b/actionpack/lib/action_view/helpers/tags/date_select.rb @@ -2,8 +2,8 @@ require 'active_support/core_ext/time/calculations' module ActionView module Helpers - module Tags - class DateSelect < Base #:nodoc: + module Tags # :nodoc: + class DateSelect < Base # :nodoc: def initialize(object_name, method_name, template_object, options, html_options) @html_options = html_options diff --git a/actionpack/lib/action_view/helpers/tags/datetime_field.rb b/actionpack/lib/action_view/helpers/tags/datetime_field.rb index e407146e96..9a2279c611 100644 --- a/actionpack/lib/action_view/helpers/tags/datetime_field.rb +++ b/actionpack/lib/action_view/helpers/tags/datetime_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class DatetimeField < TextField #:nodoc: + module Tags # :nodoc: + class DatetimeField < TextField # :nodoc: def render options = @options.stringify_keys options["value"] = @options.fetch("value") { format_date(value(object)) } diff --git a/actionpack/lib/action_view/helpers/tags/datetime_local_field.rb b/actionpack/lib/action_view/helpers/tags/datetime_local_field.rb index 6668d6d718..b4a74185d1 100644 --- a/actionpack/lib/action_view/helpers/tags/datetime_local_field.rb +++ b/actionpack/lib/action_view/helpers/tags/datetime_local_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class DatetimeLocalField < DatetimeField #:nodoc: + module Tags # :nodoc: + class DatetimeLocalField < DatetimeField # :nodoc: class << self def field_type @field_type ||= "datetime-local" diff --git a/actionpack/lib/action_view/helpers/tags/datetime_select.rb b/actionpack/lib/action_view/helpers/tags/datetime_select.rb index a32c840bce..563de1840e 100644 --- a/actionpack/lib/action_view/helpers/tags/datetime_select.rb +++ b/actionpack/lib/action_view/helpers/tags/datetime_select.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class DatetimeSelect < DateSelect #:nodoc: + module Tags # :nodoc: + class DatetimeSelect < DateSelect # :nodoc: end end end diff --git a/actionpack/lib/action_view/helpers/tags/email_field.rb b/actionpack/lib/action_view/helpers/tags/email_field.rb index 45cde507d7..7ce3ccb9bf 100644 --- a/actionpack/lib/action_view/helpers/tags/email_field.rb +++ b/actionpack/lib/action_view/helpers/tags/email_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class EmailField < TextField #:nodoc: + module Tags # :nodoc: + class EmailField < TextField # :nodoc: end end end diff --git a/actionpack/lib/action_view/helpers/tags/file_field.rb b/actionpack/lib/action_view/helpers/tags/file_field.rb index 59f2ff71b4..476b820d84 100644 --- a/actionpack/lib/action_view/helpers/tags/file_field.rb +++ b/actionpack/lib/action_view/helpers/tags/file_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class FileField < TextField #:nodoc: + module Tags # :nodoc: + class FileField < TextField # :nodoc: end end end diff --git a/actionpack/lib/action_view/helpers/tags/grouped_collection_select.rb b/actionpack/lib/action_view/helpers/tags/grouped_collection_select.rb index 507ba8835f..2ed4712dac 100644 --- a/actionpack/lib/action_view/helpers/tags/grouped_collection_select.rb +++ b/actionpack/lib/action_view/helpers/tags/grouped_collection_select.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class GroupedCollectionSelect < Base #:nodoc: + module Tags # :nodoc: + class GroupedCollectionSelect < Base # :nodoc: def initialize(object_name, method_name, template_object, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options) @collection = collection @group_method = group_method diff --git a/actionpack/lib/action_view/helpers/tags/hidden_field.rb b/actionpack/lib/action_view/helpers/tags/hidden_field.rb index a8d13dc1b1..c3757c2461 100644 --- a/actionpack/lib/action_view/helpers/tags/hidden_field.rb +++ b/actionpack/lib/action_view/helpers/tags/hidden_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class HiddenField < TextField #:nodoc: + module Tags # :nodoc: + class HiddenField < TextField # :nodoc: end end end diff --git a/actionpack/lib/action_view/helpers/tags/label.rb b/actionpack/lib/action_view/helpers/tags/label.rb index 16135fcd5a..35d3ba8434 100644 --- a/actionpack/lib/action_view/helpers/tags/label.rb +++ b/actionpack/lib/action_view/helpers/tags/label.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class Label < Base #:nodoc: + module Tags # :nodoc: + class Label < Base # :nodoc: def initialize(object_name, method_name, template_object, content_or_options = nil, options = nil) options ||= {} diff --git a/actionpack/lib/action_view/helpers/tags/month_field.rb b/actionpack/lib/action_view/helpers/tags/month_field.rb index 3d3c32d847..4c0fb846ee 100644 --- a/actionpack/lib/action_view/helpers/tags/month_field.rb +++ b/actionpack/lib/action_view/helpers/tags/month_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class MonthField < DatetimeField #:nodoc: + module Tags # :nodoc: + class MonthField < DatetimeField # :nodoc: private def format_date(value) diff --git a/actionpack/lib/action_view/helpers/tags/number_field.rb b/actionpack/lib/action_view/helpers/tags/number_field.rb index 9cd04434f0..4f95b1b4de 100644 --- a/actionpack/lib/action_view/helpers/tags/number_field.rb +++ b/actionpack/lib/action_view/helpers/tags/number_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class NumberField < TextField #:nodoc: + module Tags # :nodoc: + class NumberField < TextField # :nodoc: def render options = @options.stringify_keys diff --git a/actionpack/lib/action_view/helpers/tags/password_field.rb b/actionpack/lib/action_view/helpers/tags/password_field.rb index 6e7a4d3c36..6099fa6f19 100644 --- a/actionpack/lib/action_view/helpers/tags/password_field.rb +++ b/actionpack/lib/action_view/helpers/tags/password_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class PasswordField < TextField #:nodoc: + module Tags # :nodoc: + class PasswordField < TextField # :nodoc: def render @options = {:value => nil}.merge!(@options) super diff --git a/actionpack/lib/action_view/helpers/tags/radio_button.rb b/actionpack/lib/action_view/helpers/tags/radio_button.rb index 8a0421f061..4849c537a5 100644 --- a/actionpack/lib/action_view/helpers/tags/radio_button.rb +++ b/actionpack/lib/action_view/helpers/tags/radio_button.rb @@ -2,8 +2,8 @@ require 'action_view/helpers/tags/checkable' module ActionView module Helpers - module Tags - class RadioButton < Base #:nodoc: + module Tags # :nodoc: + class RadioButton < Base # :nodoc: include Checkable def initialize(object_name, method_name, template_object, tag_value, options) diff --git a/actionpack/lib/action_view/helpers/tags/range_field.rb b/actionpack/lib/action_view/helpers/tags/range_field.rb index 47db4680e7..f98ae88043 100644 --- a/actionpack/lib/action_view/helpers/tags/range_field.rb +++ b/actionpack/lib/action_view/helpers/tags/range_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class RangeField < NumberField #:nodoc: + module Tags # :nodoc: + class RangeField < NumberField # :nodoc: end end end diff --git a/actionpack/lib/action_view/helpers/tags/search_field.rb b/actionpack/lib/action_view/helpers/tags/search_field.rb index 818fd4b887..c09e2f1be7 100644 --- a/actionpack/lib/action_view/helpers/tags/search_field.rb +++ b/actionpack/lib/action_view/helpers/tags/search_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class SearchField < TextField #:nodoc: + module Tags # :nodoc: + class SearchField < TextField # :nodoc: def render options = @options.stringify_keys diff --git a/actionpack/lib/action_view/helpers/tags/select.rb b/actionpack/lib/action_view/helpers/tags/select.rb index 53a108b7e6..d64e2f68ef 100644 --- a/actionpack/lib/action_view/helpers/tags/select.rb +++ b/actionpack/lib/action_view/helpers/tags/select.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class Select < Base #:nodoc: + module Tags # :nodoc: + class Select < Base # :nodoc: def initialize(object_name, method_name, template_object, choices, options, html_options) @choices = choices @choices = @choices.to_a if @choices.is_a?(Range) @@ -31,7 +31,6 @@ module ActionView # # [nil, []] # { nil => [] } - # def grouped_choices? !@choices.empty? && @choices.first.respond_to?(:last) && Array === @choices.first.last end diff --git a/actionpack/lib/action_view/helpers/tags/tel_field.rb b/actionpack/lib/action_view/helpers/tags/tel_field.rb index 87c1f6b6b6..987bb9e67a 100644 --- a/actionpack/lib/action_view/helpers/tags/tel_field.rb +++ b/actionpack/lib/action_view/helpers/tags/tel_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class TelField < TextField #:nodoc: + module Tags # :nodoc: + class TelField < TextField # :nodoc: end end end diff --git a/actionpack/lib/action_view/helpers/tags/text_area.rb b/actionpack/lib/action_view/helpers/tags/text_area.rb index f74652c5e7..c81156c0c8 100644 --- a/actionpack/lib/action_view/helpers/tags/text_area.rb +++ b/actionpack/lib/action_view/helpers/tags/text_area.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class TextArea < Base #:nodoc: + module Tags # :nodoc: + class TextArea < Base # :nodoc: def render options = @options.stringify_keys add_default_name_and_id(options) diff --git a/actionpack/lib/action_view/helpers/tags/text_field.rb b/actionpack/lib/action_view/helpers/tags/text_field.rb index 024a1a8af2..baa5ff768e 100644 --- a/actionpack/lib/action_view/helpers/tags/text_field.rb +++ b/actionpack/lib/action_view/helpers/tags/text_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class TextField < Base #:nodoc: + module Tags # :nodoc: + class TextField < Base # :nodoc: def render options = @options.stringify_keys options["size"] = options["maxlength"] unless options.key?("size") diff --git a/actionpack/lib/action_view/helpers/tags/time_field.rb b/actionpack/lib/action_view/helpers/tags/time_field.rb index a3941860c9..0e90a3aed7 100644 --- a/actionpack/lib/action_view/helpers/tags/time_field.rb +++ b/actionpack/lib/action_view/helpers/tags/time_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class TimeField < DatetimeField #:nodoc: + module Tags # :nodoc: + class TimeField < DatetimeField # :nodoc: private def format_date(value) diff --git a/actionpack/lib/action_view/helpers/tags/time_select.rb b/actionpack/lib/action_view/helpers/tags/time_select.rb index 9e97deb706..0b06311d25 100644 --- a/actionpack/lib/action_view/helpers/tags/time_select.rb +++ b/actionpack/lib/action_view/helpers/tags/time_select.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class TimeSelect < DateSelect #:nodoc: + module Tags # :nodoc: + class TimeSelect < DateSelect # :nodoc: end end end diff --git a/actionpack/lib/action_view/helpers/tags/time_zone_select.rb b/actionpack/lib/action_view/helpers/tags/time_zone_select.rb index 0a176157c3..80d165ec7e 100644 --- a/actionpack/lib/action_view/helpers/tags/time_zone_select.rb +++ b/actionpack/lib/action_view/helpers/tags/time_zone_select.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class TimeZoneSelect < Base #:nodoc: + module Tags # :nodoc: + class TimeZoneSelect < Base # :nodoc: def initialize(object_name, method_name, template_object, priority_zones, options, html_options) @priority_zones = priority_zones @html_options = html_options diff --git a/actionpack/lib/action_view/helpers/tags/url_field.rb b/actionpack/lib/action_view/helpers/tags/url_field.rb index 1ffdfe0b3c..d76340178d 100644 --- a/actionpack/lib/action_view/helpers/tags/url_field.rb +++ b/actionpack/lib/action_view/helpers/tags/url_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class UrlField < TextField #:nodoc: + module Tags # :nodoc: + class UrlField < TextField # :nodoc: end end end diff --git a/actionpack/lib/action_view/helpers/tags/week_field.rb b/actionpack/lib/action_view/helpers/tags/week_field.rb index 1e13939a0a..5b3d0494e9 100644 --- a/actionpack/lib/action_view/helpers/tags/week_field.rb +++ b/actionpack/lib/action_view/helpers/tags/week_field.rb @@ -1,7 +1,7 @@ module ActionView module Helpers - module Tags - class WeekField < DatetimeField #:nodoc: + module Tags # :nodoc: + class WeekField < DatetimeField # :nodoc: private def format_date(value) From 4997831a6db59661a99d2a60aa89d1239a1e5f45 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Thu, 4 Apr 2013 16:52:39 -0500 Subject: [PATCH 28/49] fix broken format in ActionView::Helpers::AssetTagHelper [ci skip] --- .../lib/action_view/helpers/asset_tag_helper.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index bb62b45e44..73a3cf5752 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -14,7 +14,6 @@ module ActionView # # => Rails # stylesheet_link_tag("application") # # => - # module AssetTagHelper extend ActiveSupport::Concern @@ -50,7 +49,6 @@ module ActionView # # javascript_include_tag "http://www.example.com/xmlhr.js" # # => - # def javascript_include_tag(*sources) options = sources.extract_options!.stringify_keys path_options = options.extract!('protocol').symbolize_keys @@ -88,7 +86,6 @@ module ActionView # stylesheet_link_tag "random.styles", "/css/stylish" # # => # # - # def stylesheet_link_tag(*sources) options = sources.extract_options!.stringify_keys path_options = options.extract!('protocol').symbolize_keys @@ -109,10 +106,13 @@ module ActionView # +url_options+. You can modify the LINK tag itself in +tag_options+. # # ==== Options + # # * :rel - Specify the relation of this link, defaults to "alternate" # * :type - Override the auto-generated mime type # * :title - Specify the title of the link, defaults to the +type+ # + # ==== Examples + # # auto_discovery_link_tag # # => # auto_discovery_link_tag(:atom) @@ -148,9 +148,12 @@ module ActionView # you can override "rel" and "type". # # ==== Options + # # * :rel - Specify the relation of this link, defaults to 'shortcut icon' # * :type - Override the auto-generated mime type, defaults to 'image/vnd.microsoft.icon' # + # ==== Examples + # # favicon_link_tag '/myicon.ico' # # => # @@ -160,7 +163,6 @@ module ActionView # # favicon_link_tag '/mb-icon.png', rel: 'apple-touch-icon', type: 'image/png' # # => - # def favicon_link_tag(source='favicon.ico', options={}) tag('link', { :rel => 'shortcut icon', @@ -173,6 +175,7 @@ module ActionView # path or a file. # # ==== Options + # # You can add HTML attributes using the +options+. The +options+ supports # three additional keys for convenience and conformance: # @@ -250,6 +253,8 @@ module ActionView # width="30" and height="45". :size will be ignored if the # value is not in the correct format. # + # ==== Examples + # # video_tag("trailer") # # =>