From 6ae6e48b6ec50f5c2dd8f6b32c0a99372326bc41 Mon Sep 17 00:00:00 2001 From: Juanito Fatas Date: Fri, 2 Jan 2015 13:27:17 +0800 Subject: [ci skip] :scissors: a blank line from code (Active Job Guide). --- guides/source/active_job_basics.md | 1 - 1 file changed, 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/active_job_basics.md b/guides/source/active_job_basics.md index 3657d7cad7..27bfeddf34 100644 --- a/guides/source/active_job_basics.md +++ b/guides/source/active_job_basics.md @@ -303,7 +303,6 @@ Active Job provides a way to catch exceptions raised during the execution of the job: ```ruby - class GuestsCleanupJob < ActiveJob::Base queue_as :default -- cgit v1.2.3 From 9c65c539e2caa4590aded1975aead008f8135da4 Mon Sep 17 00:00:00 2001 From: claudiob Date: Wed, 24 Dec 2014 09:58:19 +0100 Subject: Add config to halt callback chain on return false This stems from [a comment](rails#17227 (comment)) by @dhh. In summary: * New Rails 5.0 apps will not accept `return false` as a way to halt callback chains, and will not display a deprecation warning. * Existing apps ported to Rails 5.0 will still accept `return false` as a way to halt callback chains, albeit with a deprecation warning. For this purpose, this commit introduces a Rails configuration option: ```ruby config.active_support.halt_callback_chains_on_return_false ``` For new Rails 5.0 apps, this option will be set to `false` by a new initializer `config/initializers/callback_terminator.rb`: ```ruby Rails.application.config.active_support.halt_callback_chains_on_return_false = false ``` For existing apps ported to Rails 5.0, the initializers above will not exist. Even running `rake rails:update` will not create this initializer. Since the default value of `halt_callback_chains_on_return_false` is set to `true`, these apps will still accept `return true` as a way to halt callback chains, displaying a deprecation warning. Developers will be able to switch to the new behavior (and stop the warning) by manually adding the line above to their `config/application.rb`. A gist with the suggested release notes to add to Rails 5.0 after this commit is available at https://gist.github.com/claudiob/614c59409fb7d11f2931 --- guides/source/configuring.md | 2 ++ guides/source/upgrading_ruby_on_rails.md | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'guides/source') diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 0a375d7cb8..5baab8a4b5 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -507,6 +507,8 @@ There are a few configuration options available in Active Support: * `config.active_support.time_precision` sets the precision of JSON encoded time values. Defaults to `3`. +* `config.active_support.halt_callback_chains_on_return_false` specifies whether ActiveRecord, ActiveModel and ActiveModel::Validations callback chains can be halted by returning `false` in a 'before' callback. Defaults to `true`. + * `ActiveSupport::Logger.silencer` is set to `false` to disable the ability to silence logging in a block. The default is `true`. * `ActiveSupport::Cache::Store.logger` specifies the logger to use within cache store operations. diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index 0b9f59bb46..c0c94475e0 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -53,6 +53,28 @@ Don't forget to review the difference, to see if there were any unexpected chang Upgrading from Rails 4.2 to Rails 5.0 ------------------------------------- +### Halting callback chains by returning `false` + +In Rails 4.2, when a 'before' callback returns `false` in ActiveRecord, +ActiveModel and ActiveModel::Validations, then the entire callback chain +is halted. In other words, successive 'before' callbacks are not executed, +and neither is the action wrapped in callbacks. + +In Rails 5.0, returning `false` in a callback will not have this side effect +of halting the callback chain. Instead, callback chains must be explicitly +halted by calling `throw(:abort)`. + +When you upgrade from Rails 4.2 to Rails 5.0, returning `false` in a callback +will still halt the callback chain, but you will receive a deprecation warning +about this upcoming change. + +When you are ready, you can opt into the new behavior and remove the deprecation +warning by adding the following configuration to your `config/application.rb`: + + config.active_support.halt_callback_chains_on_return_false = false + +See [#17227](https://github.com/rails/rails/pull/17227) for more details. + Upgrading from Rails 4.1 to Rails 4.2 ------------------------------------- -- cgit v1.2.3 From 1fd44213aa4485acdce54a1da1d7cd4aa0ac33b6 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Sat, 3 Jan 2015 19:20:54 +0100 Subject: Remove the tmp/sessions folder and its clear task Commit 1aea470 introduced this directory but this was at a time when the default way to store sessions was on the file system under the tmp directory. Let's remove references to it from the documentation as well. [Robin Dupret & yui-knk] --- guides/source/command_line.md | 11 +++++------ guides/source/getting_started.md | 2 +- guides/source/initialization.md | 15 +++++++-------- 3 files changed, 13 insertions(+), 15 deletions(-) (limited to 'guides/source') diff --git a/guides/source/command_line.md b/guides/source/command_line.md index d14cdb93f2..7567a38aef 100644 --- a/guides/source/command_line.md +++ b/guides/source/command_line.md @@ -383,8 +383,8 @@ rake db:create # Create the database from config/database.yml for the c rake log:clear # Truncates all *.log files in log/ to zero bytes (specify which logs with LOGS=test,development) rake middleware # Prints out your Rack middleware stack ... -rake tmp:clear # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear) -rake tmp:create # Creates tmp directories for sessions, cache, sockets, and pids +rake tmp:clear # Clear cache and socket files from tmp/ (narrow w/ tmp:cache:clear, tmp:sockets:clear) +rake tmp:create # Creates tmp directories for cache, sockets, and pids ``` INFO: You can also use `rake -T` to get the list of tasks. @@ -496,15 +496,14 @@ Rails comes with a test suite called Minitest. Rails owes its stability to the u ### `tmp` -The `Rails.root/tmp` directory is, like the *nix /tmp directory, the holding place for temporary files like sessions (if you're using a file store for sessions), process id files, and cached actions. +The `Rails.root/tmp` directory is, like the *nix /tmp directory, the holding place for temporary files like process id files and cached actions. The `tmp:` namespaced tasks will help you clear and create the `Rails.root/tmp` directory: * `rake tmp:cache:clear` clears `tmp/cache`. -* `rake tmp:sessions:clear` clears `tmp/sessions`. * `rake tmp:sockets:clear` clears `tmp/sockets`. -* `rake tmp:clear` clears all the three: cache, sessions and sockets. -* `rake tmp:create` creates tmp directories for sessions, cache, sockets, and pids. +* `rake tmp:clear` clears all cache and sockets files. +* `rake tmp:create` creates tmp directories for cache, sockets and pids. ### Miscellaneous diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 03a4703cb8..d80622ef00 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -174,7 +174,7 @@ of the files and folders that Rails created by default: |Rakefile|This file locates and loads tasks that can be run from the command line. The task definitions are defined throughout the components of Rails. Rather than changing Rakefile, you should add your own tasks by adding files to the lib/tasks directory of your application.| |README.rdoc|This is a brief instruction manual for your application. You should edit this file to tell others what your application does, how to set it up, and so on.| |test/|Unit tests, fixtures, and other test apparatus. These are covered in [Testing Rails Applications](testing.html).| -|tmp/|Temporary files (like cache, pid, and session files).| +|tmp/|Temporary files (like cache and pid files).| |vendor/|A place for all third-party code. In a typical Rails application this includes vendored gems.| Hello, Rails! diff --git a/guides/source/initialization.md b/guides/source/initialization.md index 0acf094f71..a93ceb7fb5 100644 --- a/guides/source/initialization.md +++ b/guides/source/initialization.md @@ -359,7 +359,7 @@ private end def create_tmp_directories - %w(cache pids sessions sockets).each do |dir_to_make| + %w(cache pids sockets).each do |dir_to_make| FileUtils.mkdir_p(File.join(Rails.root, 'tmp', dir_to_make)) end end @@ -375,13 +375,12 @@ private end ``` -This is where the first output of the Rails initialization happens. This -method creates a trap for `INT` signals, so if you `CTRL-C` the server, -it will exit the process. As we can see from the code here, it will -create the `tmp/cache`, `tmp/pids`, `tmp/sessions` and `tmp/sockets` -directories. It then calls `wrapped_app` which is responsible for -creating the Rack app, before creating and assigning an -instance of `ActiveSupport::Logger`. +This is where the first output of the Rails initialization happens. This method +creates a trap for `INT` signals, so if you `CTRL-C` the server, it will exit the +process. As we can see from the code here, it will create the `tmp/cache`, +`tmp/pids`, and `tmp/sockets` directories. It then calls `wrapped_app` which is +responsible for creating the Rack app, before creating and assigning an instance +of `ActiveSupport::Logger`. The `super` method will call `Rack::Server.start` which begins its definition like this: -- cgit v1.2.3 From 1ffd1a305c51856da09dcac43781e7f2d1b6e633 Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Tue, 30 Dec 2014 23:55:22 +0100 Subject: Section about testing xhr requests rails/rails#18305 --- guides/source/testing.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'guides/source') diff --git a/guides/source/testing.md b/guides/source/testing.md index 21b0b37efa..308d744d71 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -528,6 +528,19 @@ All of request types have equivalent methods that you can use. In a typical C.R. NOTE: Functional tests do not verify whether the specified request type is accepted by the action, we're more concerned with the result. Request tests exist for this use case to make your tests more purposeful. +### Testing XHR (AJAX) requests + +`xhr` accepts method (listed in the section above), action name and parameters: + +```ruby +test "ajax request responds with no layout" do + xhr :get, :show, id: articles(:first).id + + assert_template :index + assert_template layout: nil +end +``` + ### The Four Hashes of the Apocalypse After a request has been made and processed, you will have 4 Hash objects ready for use: -- cgit v1.2.3 From bb3c054358901e28a697643b1f76e0a29b68158e Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Sat, 3 Jan 2015 19:42:49 +0100 Subject: Avoid double negation in test guide rails/rails#18305 --- guides/source/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/testing.md b/guides/source/testing.md index 308d744d71..fac3f18eb9 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -1065,7 +1065,7 @@ class UserMailerTest < ActionMailer::TestCase # Send the email, then test that it got queued email = UserMailer.create_invite('me@example.com', 'friend@example.com', Time.now).deliver_now - assert_not ActionMailer::Base.deliveries.empty? + assert ActionMailer::Base.deliveries.present? # Test the body of the sent email contains what we expect it to assert_equal ['me@example.com'], email.from -- cgit v1.2.3 From 4a3b9c82830b08056467524081d4dd408eb6db43 Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Sat, 3 Jan 2015 20:14:05 +0100 Subject: Docs for controller test helpers rails/rails#18305 --- guides/source/testing.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'guides/source') diff --git a/guides/source/testing.md b/guides/source/testing.md index fac3f18eb9..d6e4aa36db 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -782,6 +782,41 @@ end Similar to other callbacks in Rails, the `setup` and `teardown` methods can also be used by passing a block, lambda, or method name as a symbol to call. +### Test helpers + +To avoid code duplication, you can add your own test helpers. +Sign in helper can be a good example: + +```ruby +test/test_helper.rb + +module SignInHelper + def sign_in(user) + session[:user_id] = user.id + end +end + +class ActionController::TestCase + include SignInHelper +end +``` + +```ruby +require 'test_helper' + +class ProfileControllerTest < ActionController::TestCase + + test "should show profile" do + # helper is now reusable from any controller test case + sign_in users(:david) + + get :show + assert_response :success + assert_equal users(:david), assigns(:user) + end +end +``` + Testing Routes -------------- -- cgit v1.2.3 From cf87cfeb5730ab9982adcb0a6b5608c7e75b3fa0 Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Sat, 3 Jan 2015 23:25:09 +0100 Subject: Demonstrate example of `assert_emails` in testing guide rails/rails#18305, thanks for @dhh suggestion --- guides/source/testing.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'guides/source') diff --git a/guides/source/testing.md b/guides/source/testing.md index d6e4aa36db..065ca71d48 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -1098,9 +1098,10 @@ require 'test_helper' class UserMailerTest < ActionMailer::TestCase test "invite" do # Send the email, then test that it got queued - email = UserMailer.create_invite('me@example.com', - 'friend@example.com', Time.now).deliver_now - assert ActionMailer::Base.deliveries.present? + assert_emails 1 do + email = UserMailer.create_invite('me@example.com', + 'friend@example.com', Time.now).deliver_now + end # Test the body of the sent email contains what we expect it to assert_equal ['me@example.com'], email.from -- cgit v1.2.3 From ef7274be877dc89d232b104e93b5022b56360820 Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Sat, 3 Jan 2015 23:45:50 +0100 Subject: Better example of `teardown` method in test guide rails/rails#18305, thanks for @dhh suggestion --- guides/source/testing.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'guides/source') diff --git a/guides/source/testing.md b/guides/source/testing.md index 065ca71d48..a685d95c19 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -753,10 +753,8 @@ class ArticlesControllerTest < ActionController::TestCase # called after every single test def teardown - # as we are re-initializing @article before every test - # setting it to nil here is not essential but I hope - # you understand how you can use the teardown method - @article = nil + # when controller is using cache it may be a good idea to reset it afterwards + Rails.cache.clear end test "should show article" do -- cgit v1.2.3 From 52a7873863644905e0e5ce48b8eadbdd6468dbce Mon Sep 17 00:00:00 2001 From: Max Katz Date: Sun, 4 Jan 2015 00:18:49 -0700 Subject: Add missing information regarding callbacks --- guides/source/active_record_querying.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 6cfb6c5ca5..f8c64cbd0c 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -90,7 +90,7 @@ The primary operation of `Model.find(options)` can be summarized as: * Convert the supplied options to an equivalent SQL query. * Fire the SQL query and retrieve the corresponding results from the database. * Instantiate the equivalent Ruby object of the appropriate model for every resulting row. -* Run `after_find` callbacks, if any. +* Run `after_find` and then `after_initialize` callbacks, if any. ### Retrieving a Single Object -- cgit v1.2.3 From 93559da4826546d07014f8cfa399b64b4a143127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sun, 4 Jan 2015 15:12:24 -0300 Subject: Remove debugger support bebugger doesn't work with Ruby 2.2 so we don't need to support it anymore --- guides/source/rails_on_rack.md | 1 - 1 file changed, 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/rails_on_rack.md b/guides/source/rails_on_rack.md index bfe4ced87b..561a3d9392 100644 --- a/guides/source/rails_on_rack.md +++ b/guides/source/rails_on_rack.md @@ -63,7 +63,6 @@ Here's how it loads the middlewares: ```ruby def middleware middlewares = [] - middlewares << [Rails::Rack::Debugger] if options[:debugger] middlewares << [::Rack::ContentLength] Hash.new(middlewares) end -- cgit v1.2.3 From 73a45f5ccda53e1f3c441422580b67c09c194640 Mon Sep 17 00:00:00 2001 From: Gordon Chan Date: Mon, 5 Jan 2015 11:53:40 +1300 Subject: [guides] Added newer find_by syntax example in 4.2 release notes for Adequate Record [skip ci] --- guides/source/4_2_release_notes.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'guides/source') diff --git a/guides/source/4_2_release_notes.md b/guides/source/4_2_release_notes.md index e8ddfcc9e2..faff1add9f 100644 --- a/guides/source/4_2_release_notes.md +++ b/guides/source/4_2_release_notes.md @@ -92,6 +92,9 @@ Post.find(2) # Subsequent calls reuse the cached prepared statement Post.find_by_title('first post') Post.find_by_title('second post') +Post.find_by(title: 'first post') +Post.find_by(title: 'second post') + post.comments post.comments(true) ``` -- cgit v1.2.3 From ed21e18166774a8334d703634e15626691e6e5fa Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 5 Jan 2015 14:37:52 +0100 Subject: reflects changes in 34cd7e2 in the index [ci skip] --- guides/source/documents.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'guides/source') diff --git a/guides/source/documents.yaml b/guides/source/documents.yaml index 52de98ee52..67032a31f5 100644 --- a/guides/source/documents.yaml +++ b/guides/source/documents.yaml @@ -118,9 +118,9 @@ url: initialization.html description: This guide explains the internals of the Rails initialization process as of Rails 4 - - name: Constant Autoloading and Reloading - url: constant_autoloading_and_reloading.html - description: This guide documents how constant autoloading and reloading work. + name: Autoloading and Reloading Constants + url: autoloading_and_reloading_constants.html + description: This guide documents how autoloading and reloading constants work. - name: Active Support Instrumentation work_in_progress: true -- cgit v1.2.3 From f0466b619bf5f0d79f99962f9e0e242d2ffbd699 Mon Sep 17 00:00:00 2001 From: Sammy Larbi Date: Tue, 6 Jan 2015 08:52:00 -0600 Subject: Add log_level options to configuration guide --- guides/source/configuring.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 5baab8a4b5..622f79a50f 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -110,7 +110,7 @@ numbers. New applications filter out passwords by adding the following `config.f * `config.log_formatter` defines the formatter of the Rails logger. This option defaults to an instance of `ActiveSupport::Logger::SimpleFormatter` for all modes except production, where it defaults to `Logger::Formatter`. -* `config.log_level` defines the verbosity of the Rails logger. This option defaults to `:debug` for all environments. +* `config.log_level` defines the verbosity of the Rails logger. This option defaults to `:debug` for all environments. The available log levels are: :debug, :info, :warn, :error, :fatal, and :unknown. * `config.log_tags` accepts a list of methods that the `request` object responds to. This makes it easy to tag log lines with debug information like subdomain and request id - both very helpful in debugging multi-user production applications. -- cgit v1.2.3 From e56ab7769339aa57a29e9b60bdf8dfc65f26068e Mon Sep 17 00:00:00 2001 From: claudiob Date: Tue, 6 Jan 2015 14:04:47 -0800 Subject: Fix typo "you can be disable" Closes https://github.com/rails/rails/issues/18372 [ci skip] --- guides/source/configuring.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 0a375d7cb8..66f5fe100a 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -690,7 +690,7 @@ development: pool: 5 ``` -Prepared Statements are enabled by default on PostgreSQL. You can be disable prepared statements by setting `prepared_statements` to `false`: +Prepared Statements are enabled by default on PostgreSQL. You can disable prepared statements by setting `prepared_statements` to `false`: ```yaml production: -- cgit v1.2.3 From de40b87e615252a73ea5d6b6780aa7fbf2c1cf1f Mon Sep 17 00:00:00 2001 From: Cristian Bica Date: Thu, 8 Jan 2015 11:09:41 +0200 Subject: GlobalID::Identification has been mixed into AR not AM --- guides/source/active_job_basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/active_job_basics.md b/guides/source/active_job_basics.md index 31c9406d5c..05beed8427 100644 --- a/guides/source/active_job_basics.md +++ b/guides/source/active_job_basics.md @@ -295,7 +295,7 @@ end ``` This works with any class that mixes in `GlobalID::Identification`, which -by default has been mixed into Active Model classes. +by default has been mixed into Active Record classes. Exceptions -- cgit v1.2.3 From 4d4f2df36e46558a913efb3a58a6e21fba21f937 Mon Sep 17 00:00:00 2001 From: Jose Luis Duran Date: Sun, 11 Jan 2015 17:17:21 -0200 Subject: Re-add section in SQL Caching This section was accidentally removed in 4b5e424441149cf0f61a8182f4a92999577ce59a, and partially re-added in dc14b893e5904acb37ac327478f3880f33094b7a. [ci skip] --- guides/source/caching_with_rails.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'guides/source') diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index 61b991df61..d5477eb72d 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -184,6 +184,10 @@ class ProductsController < ApplicationController end ``` +The second time the same query is run against the database, it's not actually going to hit the database. The first time the result is returned from the query it is stored in the query cache (in memory) and the second time it's pulled from memory. + +However, it's important to note that query caches are created at the start of an action and destroyed at the end of that action and thus persist only for the duration of the action. If you'd like to store query results in a more persistent fashion, you can in Rails by using low level caching. + Cache Stores ------------ -- cgit v1.2.3 From 83dd559643e429f06091fea430486a612e6b4e96 Mon Sep 17 00:00:00 2001 From: Santosh Wadghule Date: Mon, 12 Jan 2015 10:03:44 +0530 Subject: Change 'a' to 'an' for 'XML' word [ci skip] --- guides/source/active_model_basics.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides/source') diff --git a/guides/source/active_model_basics.md b/guides/source/active_model_basics.md index 8dee1cc5ec..88de4e2d9f 100644 --- a/guides/source/active_model_basics.md +++ b/guides/source/active_model_basics.md @@ -396,7 +396,7 @@ class Person end ``` -With the `to_xml` you have a XML representing the model. +With the `to_xml` you have an XML representing the model. ```ruby person = Person.new @@ -405,7 +405,7 @@ person.name = "Bob" person.to_xml # => "\n\n Bob\n\n" ``` -From a XML string you define the attributes of the model. +From an XML string you define the attributes of the model. You need to have the `attributes=` method defined on your class: ```ruby -- cgit v1.2.3 From 1cef759e1e5f672826cf332b8341f5ab35963da0 Mon Sep 17 00:00:00 2001 From: Jade McGough Date: Mon, 12 Jan 2015 00:38:10 -0500 Subject: minor grammatical fix in documentation --- guides/source/active_record_basics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/active_record_basics.md b/guides/source/active_record_basics.md index 9d2ba328ea..76516a03df 100644 --- a/guides/source/active_record_basics.md +++ b/guides/source/active_record_basics.md @@ -62,7 +62,7 @@ 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 +Rails, you'll need to write very little configuration (in some cases 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 time then this should be the default way. Thus, explicit configuration would be needed -- cgit v1.2.3 From edbc9468d54dba47ca10e1b53c5725d6bd6c50e5 Mon Sep 17 00:00:00 2001 From: Ahmad Al-kheat Date: Mon, 12 Jan 2015 16:50:17 -0500 Subject: Updated active_record_querying.md Added the SQL equivalent of the find_by method Update active_record_querying.md Update active_record_querying.md --- guides/source/active_record_querying.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'guides/source') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index f8c64cbd0c..f7ea72b68d 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -257,6 +257,12 @@ It is equivalent to writing: Client.where(first_name: 'Lifo').take ``` +The SQL equivalent of the above is: + +```sql +SELECT * FROM clients WHERE (clients.first_name = 'Lifo') LIMIT 1 +``` + The `find_by!` method behaves exactly like `find_by`, except that it will raise `ActiveRecord::RecordNotFound` if no matching record is found. For example: ```ruby -- cgit v1.2.3 From f5fced2bb94659253e87b12d35e569322b3098fd Mon Sep 17 00:00:00 2001 From: Santosh Wadghule Date: Tue, 13 Jan 2015 11:20:34 +0530 Subject: Change a to an for HTML word [ci skip] --- guides/source/layouts_and_rendering.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md index c3cde49630..e5a54c450d 100644 --- a/guides/source/layouts_and_rendering.md +++ b/guides/source/layouts_and_rendering.md @@ -255,7 +255,7 @@ extension for the layout file. #### Rendering HTML -You can send a HTML string back to the browser by using the `:html` option to +You can send an HTML string back to the browser by using the `:html` option to `render`: ```ruby -- cgit v1.2.3 From da1b8302536ebcd967010c968f64110425be1567 Mon Sep 17 00:00:00 2001 From: Rebecca Skinner Date: Tue, 13 Jan 2015 14:34:10 +0800 Subject: Digesting is now enabled by default in development --- 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 64d1c31083..01b4005d90 100644 --- a/guides/source/asset_pipeline.md +++ b/guides/source/asset_pipeline.md @@ -149,7 +149,7 @@ clients to fetch them again, even when the content of those assets has not chang Fingerprinting fixes these problems by avoiding query strings, and by ensuring that filenames are consistent based on their content. -Fingerprinting is enabled by default for production and disabled for all other +Fingerprinting is enabled by default for both the development and production environments. You can enable or disable it in your configuration through the `config.assets.digest` option. -- cgit v1.2.3 From 9c021884edabfdec6fb9671aa945a5edfb22c7d3 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Tue, 13 Jan 2015 15:54:03 -0200 Subject: Guides: Removing reference to blog that is not updated anymore [ci skip] --- guides/source/security.md | 1 - 1 file changed, 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/security.md b/guides/source/security.md index e4cc79df55..a85a247e86 100644 --- a/guides/source/security.md +++ b/guides/source/security.md @@ -1029,7 +1029,6 @@ Additional Resources The security landscape shifts and it is important to keep up to date, because missing a new vulnerability can be catastrophic. You can find additional resources about (Rails) security here: -* The Ruby on Rails security project posts security news regularly: [http://www.rorsecurity.info](http://www.rorsecurity.info) * Subscribe to the Rails security [mailing list](http://groups.google.com/group/rubyonrails-security) * [Keep up to date on the other application layers](http://secunia.com/) (they have a weekly newsletter, too) * A [good security blog](http://ha.ckers.org/blog/) including the [Cross-Site scripting Cheat Sheet](http://ha.ckers.org/xss.html) -- cgit v1.2.3 From b5c1bbbee01f64532d0cbc236ed364f1b0589a1a Mon Sep 17 00:00:00 2001 From: Derek Reeve Date: Tue, 13 Jan 2015 10:19:59 -0800 Subject: Fix form_for guide binding a form to an object. The HTML generated using url: { action: :create} will not generate the form action "/articles/create", it should generate the form action "/articles" for a new object. --- guides/source/form_helpers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guides/source') diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md index a8dcd3ee4f..4ec3a7c010 100644 --- a/guides/source/form_helpers.md +++ b/guides/source/form_helpers.md @@ -275,7 +275,7 @@ There are a few things to note here: The resulting HTML is: ```html -
+ @@ -300,7 +300,7 @@ You can create a similar binding without actually creating `` tags with th which produces the following output: ```html - +
-- cgit v1.2.3 From fe9f8fb56a5e5478bb02757110731eb890214795 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Wed, 14 Jan 2015 13:22:51 +0900 Subject: fix link in autoloading guide [ci skip] --- guides/source/autoloading_and_reloading_constants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/autoloading_and_reloading_constants.md b/guides/source/autoloading_and_reloading_constants.md index 489ea681e2..2ee2b9e25e 100644 --- a/guides/source/autoloading_and_reloading_constants.md +++ b/guides/source/autoloading_and_reloading_constants.md @@ -330,7 +330,7 @@ checked. Rails autoloading **does not emulate this algorithm**, but its starting point is the name of the constant to be autoloaded, and the parent. See more in -[Qualified References](#qualified-references). +[Qualified References](#autoloading-algorithms-qualified-references). Vocabulary -- cgit v1.2.3 From 34dc028e75137707c46f81e1db942dad6660fb31 Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Wed, 14 Jan 2015 11:47:24 +0530 Subject: Fixed spacing issues on code comments in ActiveJob Basics guide. Before: http://take.ms/z39h2 After: http://take.ms/Mo0G3 --- guides/source/active_job_basics.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'guides/source') diff --git a/guides/source/active_job_basics.md b/guides/source/active_job_basics.md index 05beed8427..838014e306 100644 --- a/guides/source/active_job_basics.md +++ b/guides/source/active_job_basics.md @@ -78,7 +78,8 @@ end Enqueue a job like so: ```ruby -# Enqueue a job to be performed as soon the queueing system is free. +# Enqueue a job to be performed as soon the queueing system is +# free. MyJob.perform_later record ``` @@ -114,8 +115,9 @@ You can easily set your queueing backend: # config/application.rb module YourApp class Application < Rails::Application - # Be sure to have the adapter's gem in your Gemfile and follow - # the adapter's specific installation and deployment instructions. + # Be sure to have the adapter's gem in your Gemfile + # and follow the adapter's specific installation + # and deployment instructions. config.active_job.queue_adapter = :sidekiq end end @@ -153,8 +155,8 @@ class GuestsCleanupJob < ActiveJob::Base end # Now your job will run on queue production_low_priority on your -# production environment and on staging_low_priority on your staging -# environment +# production environment and on staging_low_priority +# on your staging environment ``` The default queue name prefix delimiter is '\_'. This can be changed by setting @@ -176,8 +178,8 @@ class GuestsCleanupJob < ActiveJob::Base end # Now your job will run on queue production.low_priority on your -# production environment and on staging.low_priority on your staging -# environment +# production environment and on staging.low_priority +# on your staging environment ``` If you want more control on what queue a job will be run you can pass a `:queue` -- cgit v1.2.3 From 5cfaf5a46eb154f98ba8963bdcfade0afdc618ad Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Wed, 14 Jan 2015 11:52:13 +0530 Subject: - Changed `IN` to `ON` in markdown renderer condition - Changed `IN` to `ON` in all note sentences in guides. --- guides/source/2_2_release_notes.md | 2 +- guides/source/2_3_release_notes.md | 2 +- guides/source/3_0_release_notes.md | 2 +- guides/source/3_1_release_notes.md | 2 +- guides/source/3_2_release_notes.md | 2 +- guides/source/4_0_release_notes.md | 2 +- guides/source/4_1_release_notes.md | 2 +- guides/source/4_2_release_notes.md | 2 +- guides/source/action_controller_overview.md | 2 +- guides/source/action_mailer_basics.md | 2 +- guides/source/action_view_overview.md | 2 +- guides/source/active_job_basics.md | 2 +- guides/source/active_model_basics.md | 2 +- guides/source/active_record_basics.md | 2 +- guides/source/active_record_callbacks.md | 2 +- guides/source/active_record_migrations.md | 2 +- guides/source/active_record_postgresql.md | 2 +- guides/source/active_record_querying.md | 2 +- guides/source/active_record_validations.md | 2 +- guides/source/active_support_core_extensions.md | 2 +- guides/source/active_support_instrumentation.md | 2 +- guides/source/api_documentation_guidelines.md | 2 +- guides/source/asset_pipeline.md | 2 +- guides/source/association_basics.md | 2 +- guides/source/autoloading_and_reloading_constants.md | 2 +- guides/source/caching_with_rails.md | 2 +- guides/source/command_line.md | 2 +- guides/source/configuring.md | 2 +- guides/source/contributing_to_ruby_on_rails.md | 2 +- guides/source/debugging_rails_applications.md | 2 +- guides/source/development_dependencies_install.md | 2 +- guides/source/engines.md | 2 +- guides/source/form_helpers.md | 2 +- guides/source/generators.md | 2 +- guides/source/getting_started.md | 2 +- guides/source/i18n.md | 2 +- guides/source/initialization.md | 2 +- guides/source/layouts_and_rendering.md | 2 +- guides/source/maintenance_policy.md | 2 +- guides/source/nested_model_forms.md | 2 +- guides/source/plugins.md | 2 +- guides/source/profiling.md | 2 +- guides/source/rails_application_templates.md | 2 +- guides/source/rails_on_rack.md | 2 +- guides/source/routing.md | 2 +- guides/source/ruby_on_rails_guides_guidelines.md | 2 +- guides/source/security.md | 2 +- guides/source/testing.md | 2 +- guides/source/upgrading_ruby_on_rails.md | 2 +- guides/source/working_with_javascript_in_rails.md | 2 +- 50 files changed, 50 insertions(+), 50 deletions(-) (limited to 'guides/source') diff --git a/guides/source/2_2_release_notes.md b/guides/source/2_2_release_notes.md index 019da08687..be00087f63 100644 --- a/guides/source/2_2_release_notes.md +++ b/guides/source/2_2_release_notes.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Ruby on Rails 2.2 Release Notes =============================== diff --git a/guides/source/2_3_release_notes.md b/guides/source/2_3_release_notes.md index 4ac1529e76..328656f4a4 100644 --- a/guides/source/2_3_release_notes.md +++ b/guides/source/2_3_release_notes.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Ruby on Rails 2.3 Release Notes =============================== diff --git a/guides/source/3_0_release_notes.md b/guides/source/3_0_release_notes.md index 3d7966e50b..9ad32e8168 100644 --- a/guides/source/3_0_release_notes.md +++ b/guides/source/3_0_release_notes.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Ruby on Rails 3.0 Release Notes =============================== diff --git a/guides/source/3_1_release_notes.md b/guides/source/3_1_release_notes.md index 8728750966..e187e5f9ab 100644 --- a/guides/source/3_1_release_notes.md +++ b/guides/source/3_1_release_notes.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Ruby on Rails 3.1 Release Notes =============================== diff --git a/guides/source/3_2_release_notes.md b/guides/source/3_2_release_notes.md index 0b28aac9ce..6ddf77d9c0 100644 --- a/guides/source/3_2_release_notes.md +++ b/guides/source/3_2_release_notes.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Ruby on Rails 3.2 Release Notes =============================== diff --git a/guides/source/4_0_release_notes.md b/guides/source/4_0_release_notes.md index 5f52c33746..67f4a3c02c 100644 --- a/guides/source/4_0_release_notes.md +++ b/guides/source/4_0_release_notes.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Ruby on Rails 4.0 Release Notes =============================== diff --git a/guides/source/4_1_release_notes.md b/guides/source/4_1_release_notes.md index dbc151c0ca..8d5557be6e 100644 --- a/guides/source/4_1_release_notes.md +++ b/guides/source/4_1_release_notes.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Ruby on Rails 4.1 Release Notes =============================== diff --git a/guides/source/4_2_release_notes.md b/guides/source/4_2_release_notes.md index faff1add9f..366d9d26b4 100644 --- a/guides/source/4_2_release_notes.md +++ b/guides/source/4_2_release_notes.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Ruby on Rails 4.2 Release Notes =============================== diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md index 36d1b6de83..80000baf66 100644 --- a/guides/source/action_controller_overview.md +++ b/guides/source/action_controller_overview.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Action Controller Overview ========================== diff --git a/guides/source/action_mailer_basics.md b/guides/source/action_mailer_basics.md index c586675ee5..e55ff16495 100644 --- a/guides/source/action_mailer_basics.md +++ b/guides/source/action_mailer_basics.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Action Mailer Basics ==================== diff --git a/guides/source/action_view_overview.md b/guides/source/action_view_overview.md index a6bde4f517..665a2b71ff 100644 --- a/guides/source/action_view_overview.md +++ b/guides/source/action_view_overview.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Action View Overview ==================== diff --git a/guides/source/active_job_basics.md b/guides/source/active_job_basics.md index 31c9406d5c..53588bdd1d 100644 --- a/guides/source/active_job_basics.md +++ b/guides/source/active_job_basics.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Active Job Basics ================= diff --git a/guides/source/active_model_basics.md b/guides/source/active_model_basics.md index 8dee1cc5ec..db6981d2d5 100644 --- a/guides/source/active_model_basics.md +++ b/guides/source/active_model_basics.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Active Model Basics =================== diff --git a/guides/source/active_record_basics.md b/guides/source/active_record_basics.md index 9d2ba328ea..2066337a9e 100644 --- a/guides/source/active_record_basics.md +++ b/guides/source/active_record_basics.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Active Record Basics ==================== diff --git a/guides/source/active_record_callbacks.md b/guides/source/active_record_callbacks.md index 9d3a8c3af6..e65ab802c0 100644 --- a/guides/source/active_record_callbacks.md +++ b/guides/source/active_record_callbacks.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Active Record Callbacks ======================= diff --git a/guides/source/active_record_migrations.md b/guides/source/active_record_migrations.md index 8ae282bad2..97cabc1728 100644 --- a/guides/source/active_record_migrations.md +++ b/guides/source/active_record_migrations.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Active Record Migrations ======================== diff --git a/guides/source/active_record_postgresql.md b/guides/source/active_record_postgresql.md index fa0f31cbbd..4d9c1776f4 100644 --- a/guides/source/active_record_postgresql.md +++ b/guides/source/active_record_postgresql.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Active Record and PostgreSQL ============================ diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index f8c64cbd0c..6ca658802d 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Active Record Query Interface ============================= diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md index 8c832bafff..c9af70934a 100644 --- a/guides/source/active_record_validations.md +++ b/guides/source/active_record_validations.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Active Record Validations ========================= diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index ba839e1723..080cc41e87 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Active Support Core Extensions ============================== diff --git a/guides/source/active_support_instrumentation.md b/guides/source/active_support_instrumentation.md index 0aa74e387d..9d9f40e956 100644 --- a/guides/source/active_support_instrumentation.md +++ b/guides/source/active_support_instrumentation.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Active Support Instrumentation ============================== diff --git a/guides/source/api_documentation_guidelines.md b/guides/source/api_documentation_guidelines.md index d481700709..b385bdbe83 100644 --- a/guides/source/api_documentation_guidelines.md +++ b/guides/source/api_documentation_guidelines.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** API Documentation Guidelines ============================ diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md index 64d1c31083..1ee1eede9b 100644 --- a/guides/source/asset_pipeline.md +++ b/guides/source/asset_pipeline.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** The Asset Pipeline ================== diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index 95c7e747ef..dab885a8fb 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Active Record Associations ========================== diff --git a/guides/source/autoloading_and_reloading_constants.md b/guides/source/autoloading_and_reloading_constants.md index 489ea681e2..77fc377440 100644 --- a/guides/source/autoloading_and_reloading_constants.md +++ b/guides/source/autoloading_and_reloading_constants.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Autoloading and Reloading Constants =================================== diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index 61b991df61..36d5826134 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Caching with Rails: An overview =============================== diff --git a/guides/source/command_line.md b/guides/source/command_line.md index 7567a38aef..78f26ccefa 100644 --- a/guides/source/command_line.md +++ b/guides/source/command_line.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** The Rails Command Line ====================== diff --git a/guides/source/configuring.md b/guides/source/configuring.md index 622f79a50f..cc3d840271 100644 --- a/guides/source/configuring.md +++ b/guides/source/configuring.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Configuring Rails Applications ============================== diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index db3f19f8ac..84e6627c3a 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Contributing to Ruby on Rails ============================= diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md index cef9ac083b..a788dd48ad 100644 --- a/guides/source/debugging_rails_applications.md +++ b/guides/source/debugging_rails_applications.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Debugging Rails Applications ============================ diff --git a/guides/source/development_dependencies_install.md b/guides/source/development_dependencies_install.md index 9eacc3a2fe..989b29956c 100644 --- a/guides/source/development_dependencies_install.md +++ b/guides/source/development_dependencies_install.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Development Dependencies Install ================================ diff --git a/guides/source/engines.md b/guides/source/engines.md index 731178787f..6eb558885f 100644 --- a/guides/source/engines.md +++ b/guides/source/engines.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Getting Started with Engines ============================ diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md index a8dcd3ee4f..827f515fac 100644 --- a/guides/source/form_helpers.md +++ b/guides/source/form_helpers.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Form Helpers ============ diff --git a/guides/source/generators.md b/guides/source/generators.md index 05bf07b4c8..14f451cbc9 100644 --- a/guides/source/generators.md +++ b/guides/source/generators.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Creating and Customizing Rails Generators & Templates ===================================================== diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index d80622ef00..fecd006a5f 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Getting Started with Rails ========================== diff --git a/guides/source/i18n.md b/guides/source/i18n.md index bd6babff41..779526d733 100644 --- a/guides/source/i18n.md +++ b/guides/source/i18n.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Rails Internationalization (I18n) API ===================================== diff --git a/guides/source/initialization.md b/guides/source/initialization.md index a93ceb7fb5..8fbb234698 100644 --- a/guides/source/initialization.md +++ b/guides/source/initialization.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** The Rails Initialization Process ================================ diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md index c3cde49630..144aaa4d8b 100644 --- a/guides/source/layouts_and_rendering.md +++ b/guides/source/layouts_and_rendering.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Layouts and Rendering in Rails ============================== diff --git a/guides/source/maintenance_policy.md b/guides/source/maintenance_policy.md index 45cdc549f7..50308f505a 100644 --- a/guides/source/maintenance_policy.md +++ b/guides/source/maintenance_policy.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Maintenance Policy for Ruby on Rails ==================================== diff --git a/guides/source/nested_model_forms.md b/guides/source/nested_model_forms.md index 44236ad239..1937369776 100644 --- a/guides/source/nested_model_forms.md +++ b/guides/source/nested_model_forms.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Rails Nested Model Forms ======================== diff --git a/guides/source/plugins.md b/guides/source/plugins.md index bd884441ac..10738320ef 100644 --- a/guides/source/plugins.md +++ b/guides/source/plugins.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** The Basics of Creating Rails Plugins ==================================== diff --git a/guides/source/profiling.md b/guides/source/profiling.md index 695b09647f..ce093f78ba 100644 --- a/guides/source/profiling.md +++ b/guides/source/profiling.md @@ -1,4 +1,4 @@ -*DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +*DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** A Guide to Profiling Rails Applications ======================================= diff --git a/guides/source/rails_application_templates.md b/guides/source/rails_application_templates.md index 0db777b9bb..b3e1874048 100644 --- a/guides/source/rails_application_templates.md +++ b/guides/source/rails_application_templates.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Rails Application Templates =========================== diff --git a/guides/source/rails_on_rack.md b/guides/source/rails_on_rack.md index 561a3d9392..21be74beba 100644 --- a/guides/source/rails_on_rack.md +++ b/guides/source/rails_on_rack.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Rails on Rack ============= diff --git a/guides/source/routing.md b/guides/source/routing.md index 893cedeefc..a689e131ff 100644 --- a/guides/source/routing.md +++ b/guides/source/routing.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Rails Routing from the Outside In ================================= diff --git a/guides/source/ruby_on_rails_guides_guidelines.md b/guides/source/ruby_on_rails_guides_guidelines.md index 0ecf8a80df..1323742488 100644 --- a/guides/source/ruby_on_rails_guides_guidelines.md +++ b/guides/source/ruby_on_rails_guides_guidelines.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Ruby on Rails Guides Guidelines =============================== diff --git a/guides/source/security.md b/guides/source/security.md index e4cc79df55..3d41f1a6df 100644 --- a/guides/source/security.md +++ b/guides/source/security.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Ruby on Rails Security Guide ============================ diff --git a/guides/source/testing.md b/guides/source/testing.md index 21b0b37efa..8456a8c4a8 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** A Guide to Testing Rails Applications ===================================== diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md index c0c94475e0..d7fbe575c2 100644 --- a/guides/source/upgrading_ruby_on_rails.md +++ b/guides/source/upgrading_ruby_on_rails.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** A Guide for Upgrading Ruby on Rails =================================== diff --git a/guides/source/working_with_javascript_in_rails.md b/guides/source/working_with_javascript_in_rails.md index 5131f809d7..367abddcfa 100644 --- a/guides/source/working_with_javascript_in_rails.md +++ b/guides/source/working_with_javascript_in_rails.md @@ -1,4 +1,4 @@ -**DO NOT READ THIS FILE IN GITHUB, GUIDES ARE PUBLISHED IN http://guides.rubyonrails.org.** +**DO NOT READ THIS FILE ON GITHUB, GUIDES ARE PUBLISHED ON http://guides.rubyonrails.org.** Working with JavaScript in Rails ================================ -- cgit v1.2.3 From bd13ff68ef46ae4389c7afd7a9450e7422813948 Mon Sep 17 00:00:00 2001 From: Prathamesh Sonpatki Date: Wed, 14 Jan 2015 16:37:36 +0530 Subject: Changed "in GitHub" to "on GitHub" [ci skip] - Followup of https://github.com/rails/rails/pull/18503. --- guides/source/contributing_to_ruby_on_rails.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index 84e6627c3a..7381521658 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -26,7 +26,7 @@ NOTE: Bugs in the most recent released version of Ruby on Rails are likely to ge ### Creating a Bug Report -If you've found a problem in Ruby on Rails which is not a security risk, do a search in GitHub under [Issues](https://github.com/rails/rails/issues) in case it has already been reported. If you are unable to find any open GitHub issues addressing the problem you found, your next step will be to [open a new one](https://github.com/rails/rails/issues/new). (See the next section for reporting security issues.) +If you've found a problem in Ruby on Rails which is not a security risk, do a search on GitHub under [Issues](https://github.com/rails/rails/issues) in case it has already been reported. If you are unable to find any open GitHub issues addressing the problem you found, your next step will be to [open a new one](https://github.com/rails/rails/issues/new). (See the next section for reporting security issues.) Your issue report should contain a title and a clear description of the issue at the bare minimum. You should include as much relevant information as possible and should at least post a code sample that demonstrates the issue. It would be even better if you could include a unit test that shows how the expected behavior is not occurring. Your goal should be to make it easy for yourself - and others - to replicate the bug and figure out a fix. -- cgit v1.2.3 From bf5f03849127602f486be450e7ccb769ea8ff959 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 15 Jan 2015 16:11:34 -0200 Subject: Adding tip about jQuery UJS [ci skip] Reference #18533 --- guides/source/getting_started.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'guides/source') diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index fecd006a5f..cc916e86d2 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -1485,6 +1485,9 @@ Without this file, the confirmation dialog box wouldn't appear. ![Confirm Dialog](images/getting_started/confirm_dialog.png) +TIP: Learn more about jQuery Unobtrusive Adapter (jQuery UJS) on +[Working With Javascript in Rails](working_with_javascript_in_rails.html) guide. + Congratulations, you can now create, show, list, update and destroy articles. -- cgit v1.2.3 From 3447e765361f524d365ffd02b24abad15f711ea4 Mon Sep 17 00:00:00 2001 From: Toby Woller Date: Tue, 13 Jan 2015 10:28:28 -0800 Subject: Use consistent anchor text throughout the guide. Change all of anchor text in the nav links to `Back` and `Edit` Use `Edit | Back` on pages that use both links to conform to what scaffolding generates. Use consistent anchor text throughout the guide. Change all of anchor text in the nav links to `Back` and `Edit` Use `Edit | Back` on pages that use both links to conform to what scaffolding generates. --- guides/source/getting_started.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index d80622ef00..7525cebfee 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -1271,8 +1271,8 @@ bottom of the template: ```html+erb ... -<%= link_to 'Back', articles_path %> | -<%= link_to 'Edit', edit_article_path(@article) %> +<%= link_to 'Edit', edit_article_path(@article) %> | +<%= link_to 'Back', articles_path %> ``` And here's how our app looks so far: @@ -1681,8 +1681,8 @@ So first, we'll wire up the Article show template

<% end %> -<%= link_to 'Back', articles_path %> | -<%= link_to 'Edit', edit_article_path(@article) %> +<%= link_to 'Edit', edit_article_path(@article) %> | +<%= link_to 'Back', articles_path %> ``` This adds a form on the `Article` show page that creates a new comment by @@ -1762,8 +1762,8 @@ add that to the `app/views/articles/show.html.erb`.

<% end %> -<%= link_to 'Edit Article', edit_article_path(@article) %> | -<%= link_to 'Back to Articles', articles_path %> +<%= link_to 'Edit', edit_article_path(@article) %> | +<%= link_to 'Back', articles_path %> ``` Now you can add articles and comments to your blog and have them show up in the @@ -1828,8 +1828,8 @@ following:

<% end %> -<%= link_to 'Edit Article', edit_article_path(@article) %> | -<%= link_to 'Back to Articles', articles_path %> +<%= link_to 'Edit', edit_article_path(@article) %> | +<%= link_to 'Back', articles_path %> ``` This will now render the partial in `app/views/comments/_comment.html.erb` once @@ -1878,8 +1878,8 @@ Then you make the `app/views/articles/show.html.erb` look like the following:

Add a comment:

<%= render 'comments/form' %> -<%= link_to 'Edit Article', edit_article_path(@article) %> | -<%= link_to 'Back to Articles', articles_path %> +<%= link_to 'Edit', edit_article_path(@article) %> | +<%= link_to 'Back', articles_path %> ``` The second render just defines the partial template we want to render, -- cgit v1.2.3 From 8c976c3843481d17d35d5f506c3d94483084d689 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 15 Jan 2015 15:55:15 -0200 Subject: Improving 'Customizing Form Builder' section with example [ci skip] --- guides/source/form_helpers.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md index 4c02c99cc7..90004c611b 100644 --- a/guides/source/form_helpers.md +++ b/guides/source/form_helpers.md @@ -687,7 +687,14 @@ class LabellingFormBuilder < ActionView::Helpers::FormBuilder end ``` -If you reuse this frequently you could define a `labeled_form_for` helper that automatically applies the `builder: LabellingFormBuilder` option. +If you reuse this frequently you could define a `labeled_form_for` helper that automatically applies the `builder: LabellingFormBuilder` option: + +```ruby +def labeled_form_for(record, options = {}, &block) + options.merge! builder: LabellingFormBuilder + form_for record, options, &block +end +``` The form builder used also determines what happens when you do -- cgit v1.2.3 From 780be3995517435695b73ac7201a3bd9525fff1e Mon Sep 17 00:00:00 2001 From: Jared Fine Date: Fri, 16 Jan 2015 15:08:52 -0500 Subject: Underscore typo [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 779526d733..fd2051e675 100644 --- a/guides/source/i18n.md +++ b/guides/source/i18n.md @@ -530,7 +530,7 @@ Thus the following calls are equivalent: ```ruby I18n.t 'activerecord.errors.messages.record_invalid' -I18n.t 'errors.messages.record_invalid', scope: :active_record +I18n.t 'errors.messages.record_invalid', scope: :activerecord I18n.t :record_invalid, scope: 'activerecord.errors.messages' I18n.t :record_invalid, scope: [:activerecord, :errors, :messages] ``` -- cgit v1.2.3 From c0be81cfad2b6727496d1e28f727ac05a0368942 Mon Sep 17 00:00:00 2001 From: Oge Nnadi Date: Fri, 16 Jan 2015 21:22:29 -0800 Subject: Typo fix --- guides/source/active_record_querying.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 434b308170..0019ac9297 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -1134,7 +1134,7 @@ This would generate a query which contains a `LEFT OUTER JOIN` whereas the If there was no `where` condition, this would generate the normal set of two queries. NOTE: Using `where` like this will only work when you pass it a Hash. For -SQL-fragments you need use `references` to force joined tables: +SQL-fragments you need to use `references` to force joined tables: ```ruby Article.includes(:comments).where("comments.visible = true").references(:comments) -- cgit v1.2.3 From 3686513de755762842f0dad949164dea80ad6b36 Mon Sep 17 00:00:00 2001 From: Oge Nnadi Date: Fri, 16 Jan 2015 21:56:34 -0800 Subject: Fixed extraneous quoting --- guides/source/active_record_querying.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 0019ac9297..373a98bb85 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -1275,7 +1275,7 @@ User.active.where(state: 'finished') # SELECT "users".* FROM "users" WHERE "users"."state" = 'active' AND "users"."state" = 'finished' ``` -If we do want the `last where clause` to win then `Relation#merge` can +If we do want the last `where` clause to win then `Relation#merge` can be used. ```ruby -- cgit v1.2.3 From 03d049cca2ae0cd39a25fa0beb0548d3657f6689 Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sat, 17 Jan 2015 23:52:53 +0900 Subject: [ci skip] Change to the passive voice --- guides/source/autoloading_and_reloading_constants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/autoloading_and_reloading_constants.md b/guides/source/autoloading_and_reloading_constants.md index f32714f893..115074db3a 100644 --- a/guides/source/autoloading_and_reloading_constants.md +++ b/guides/source/autoloading_and_reloading_constants.md @@ -236,7 +236,7 @@ end ``` `Post` is not syntax for a class. Rather, `Post` is a regular Ruby constant. If -all is good, the constant evaluates to an object that responds to `all`. +all is good, the constant is evaluated to an object that responds to `all`. That is why we talk about *constant* autoloading, Rails has the ability to load constants on the fly. -- cgit v1.2.3 From e0badb4a062d62cd51df6a905a5bcb148d575295 Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Sat, 17 Jan 2015 22:22:37 +0530 Subject: Removed documentation of deprecated removed methods [ci skip] --- guides/source/active_support_core_extensions.md | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'guides/source') diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index 080cc41e87..d817885169 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -467,7 +467,7 @@ C.new(0, 1).instance_variable_names # => ["@x", "@y"] NOTE: Defined in `active_support/core_ext/object/instance_variables.rb`. -### Silencing Warnings, Streams, and Exceptions +### Silencing Warnings and Exceptions The methods `silence_warnings` and `enable_warnings` change the value of `$VERBOSE` accordingly for the duration of their block, and reset it afterwards: @@ -475,26 +475,10 @@ The methods `silence_warnings` and `enable_warnings` change the value of `$VERBO silence_warnings { Object.const_set "RAILS_DEFAULT_LOGGER", logger } ``` -You can silence any stream while a block runs with `silence_stream`: - -```ruby -silence_stream(STDOUT) do - # STDOUT is silent here -end -``` - -The `quietly` method addresses the common use case where you want to silence STDOUT and STDERR, even in subprocesses: - -```ruby -quietly { system 'bundle install' } -``` - -For example, the railties test suite uses that one in a few places to prevent command messages from being echoed intermixed with the progress status. - Silencing exceptions is also possible with `suppress`. This method receives an arbitrary number of exception classes. If an exception is raised during the execution of the block and is `kind_of?` any of the arguments, `suppress` captures it and returns silently. Otherwise the exception is reraised: ```ruby -# If the user is locked the increment is lost, no big deal. +# If the user is locked, the increment is lost, no big deal. suppress(ActiveRecord::StaleObjectError) do current_user.increment! :visits end -- cgit v1.2.3 From 51f97d02cc6bf9bee0254da787de48d4c93365ba Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sun, 18 Jan 2015 11:17:39 +0900 Subject: [ci skip] fix positions of parentheses --- guides/source/autoloading_and_reloading_constants.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'guides/source') diff --git a/guides/source/autoloading_and_reloading_constants.md b/guides/source/autoloading_and_reloading_constants.md index 115074db3a..0dddc4e245 100644 --- a/guides/source/autoloading_and_reloading_constants.md +++ b/guides/source/autoloading_and_reloading_constants.md @@ -685,12 +685,12 @@ creates an empty module and assigns it to the `Admin` constant on the fly. ### Generic Procedure Relative references are reported to be missing in the cref where they were hit, -and qualified references are reported to be missing in their parent. (See +and qualified references are reported to be missing in their parent (see [Resolution Algorithm for Relative Constants](#resolution-algorithm-for-relative-constants) at the beginning of this guide for the definition of *cref*, and [Resolution Algorithm for Qualified Constants](#resolution-algorithm-for-qualified-constants) for the definition of -*parent*.) +*parent*). The procedure to autoload constant `C` in an arbitrary situation is as follows: @@ -868,8 +868,8 @@ end ``` To resolve `User` Ruby checks `Admin` in the former case, but it does not in -the latter because it does not belong to the nesting. (See [Nesting](#nesting) -and [Resolution Algorithms](#resolution-algorithms).) +the latter because it does not belong to the nesting (see [Nesting](#nesting) +and [Resolution Algorithms](#resolution-algorithms)). Unfortunately Rails autoloading does not know the nesting in the spot where the constant was missing and so it is not able to act as Ruby would. In particular, @@ -1284,7 +1284,7 @@ c.user # NameError: uninitialized constant C::User ``` because it detects that a parent namespace already has the constant (see [Qualified -References](#autoloading-algorithms-qualified-references).) +References](#autoloading-algorithms-qualified-references)). As with pure Ruby, within the body of a direct descendant of `BasicObject` use always absolute constant paths: -- cgit v1.2.3 From 75b382301de3cda2a0be1a15e533417e8060d80b Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sun, 18 Jan 2015 11:43:03 +0900 Subject: [ci skip] Move a introduction of `Module.nesting` Move a introduction of `Module.nesting` to the beginning of sentence. This change will help reader to try to dump `nesting`. --- guides/source/autoloading_and_reloading_constants.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'guides/source') diff --git a/guides/source/autoloading_and_reloading_constants.md b/guides/source/autoloading_and_reloading_constants.md index 115074db3a..408b1a9a12 100644 --- a/guides/source/autoloading_and_reloading_constants.md +++ b/guides/source/autoloading_and_reloading_constants.md @@ -80,7 +80,8 @@ end ``` The *nesting* at any given place is the collection of enclosing nested class and -module objects outwards. For example, in the previous example, the nesting at +module objects outwards. The nesting at any given place can be inspected with +`Module.nesting`. For example, in the previous example, the nesting at (1) is ```ruby @@ -153,8 +154,6 @@ the blocks that may be passed to `Class.new` and `Module.new` do not get the class or module being defined pushed to their nesting. That's one of the differences between defining classes and modules in one way or another. -The nesting at any given place can be inspected with `Module.nesting`. - ### Class and Module Definitions are Constant Assignments Let's suppose the following snippet creates a class (rather than reopening it): -- cgit v1.2.3 From 8f2264cb528ed4b91d307cb2ad4d3b6917a00eb8 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Sun, 18 Jan 2015 15:29:30 +0900 Subject: remove reference to `Logger` core extensions from guide [ci skip] --- guides/source/active_support_core_extensions.md | 44 ------------------------- 1 file changed, 44 deletions(-) (limited to 'guides/source') diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index d817885169..0fbd6ed7e1 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -3797,50 +3797,6 @@ WARNING. If the argument is an `IO` it needs to respond to `rewind` to be able t NOTE: Defined in `active_support/core_ext/marshal.rb`. -Extensions to `Logger` ----------------------- - -### `around_[level]` - -Takes two arguments, a `before_message` and `after_message` and calls the current level method on the `Logger` instance, passing in the `before_message`, then the specified message, then the `after_message`: - -```ruby -logger = Logger.new("log/development.log") -logger.around_info("before", "after") { |logger| logger.info("during") } -``` - -### `silence` - -Silences every log level lesser to the specified one for the duration of the given block. Log level orders are: debug, info, error and fatal. - -```ruby -logger = Logger.new("log/development.log") -logger.silence(Logger::INFO) do - logger.debug("In space, no one can hear you scream.") - logger.info("Scream all you want, small mailman!") -end -``` - -### `datetime_format=` - -Modifies the datetime format output by the formatter class associated with this logger. If the formatter class does not have a `datetime_format` method then this is ignored. - -```ruby -class Logger::FormatWithTime < Logger::Formatter - cattr_accessor(:datetime_format) { "%Y%m%d%H%m%S" } - - def self.call(severity, timestamp, progname, msg) - "#{timestamp.strftime(datetime_format)} -- #{String === msg ? msg : msg.inspect}\n" - end -end - -logger = Logger.new("log/development.log") -logger.formatter = Logger::FormatWithTime -logger.info("<- is the current time") -``` - -NOTE: Defined in `active_support/core_ext/logger.rb`. - Extensions to `NameError` ------------------------- -- cgit v1.2.3 From cb74473db68900d336844d840dda6e10dc03fde1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Wn=C4=99trzak?= Date: Sun, 4 Jan 2015 09:18:03 +0100 Subject: Add ActiveModel::Errors#details To be able to return type of validator, one can now call `details` on Errors instance: ```ruby class User < ActiveRecord::Base validates :name, presence: true end ``` ```ruby user = User.new; user.valid?; user.errors.details => {name: [{error: :blank}]} ``` --- guides/source/active_record_validations.md | 58 ++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) (limited to 'guides/source') diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md index c9af70934a..84925072f2 100644 --- a/guides/source/active_record_validations.md +++ b/guides/source/active_record_validations.md @@ -227,8 +227,26 @@ end ``` We'll cover validation errors in greater depth in the [Working with Validation -Errors](#working-with-validation-errors) section. For now, let's turn to the -built-in validation helpers that Rails provides by default. +Errors](#working-with-validation-errors) section. + +### `errors.details` + +To check what validator type was used on invalid attribute, you can use +`errors.details[:attribute]`. It returns array of hashes where under `:error` + key you will find symbol of used validator. + +```ruby +class Person < ActiveRecord::Base + validates :name, presence: true +end + +>> person = Person.new +>> person.valid? +>> person.errors.details[:name] #=> [{error: :blank}] +``` + +Using `details` with custom validators are covered in the [Working with +Validation Errors](#working-with-validation-errors) section. Validation Helpers ------------------ @@ -1074,6 +1092,42 @@ Another way to do this is using `[]=` setter # => ["Name cannot contain the characters !@#%*()_-+="] ``` +### `errors.details` + +You can add validator type to details hash when using `errors.add` method. + +```ruby + class Person < ActiveRecord::Base + def a_method_used_for_validation_purposes + errors.add(:name, :invalid_characters) + end + end + + person = Person.create(name: "!@#") + + person.errors.details[:name] + # => [{error: :invalid_characters}] +``` + +To improve error details to contain not allowed characters set, you can +pass additional options to `errors.add` method. + +```ruby + class Person < ActiveRecord::Base + def a_method_used_for_validation_purposes + errors.add(:name, :invalid_characters, not_allowed: "!@#%*()_-+=") + end + end + + person = Person.create(name: "!@#") + + person.errors.details[:name] + # => [{error: :invalid_characters, not_allowed: "!@#%*()_-+="}] +``` + +All built in Rails validators populate details hash with corresponding +validator types. + ### `errors[:base]` You can add error messages that are related to the object's state as a whole, instead of being related to a specific attribute. You can use this method when you want to say that the object is invalid, no matter the values of its attributes. Since `errors[:base]` is an array, you can simply add a string to it and it will be used as an error message. -- cgit v1.2.3 From 3d78c8f59e8a22427ef88a0cf9e1171da2497293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Wn=C4=99trzak?= Date: Wed, 21 Jan 2015 09:45:18 +0100 Subject: Add missing options to Error Message Interpolation guide [CI skip] --- guides/source/i18n.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/i18n.md b/guides/source/i18n.md index fd2051e675..fbee267975 100644 --- a/guides/source/i18n.md +++ b/guides/source/i18n.md @@ -809,7 +809,7 @@ So, for example, instead of the default error message `"cannot be blank"` you co | validation | with option | message | interpolation | | ------------ | ------------------------- | ------------------------- | ------------- | -| confirmation | - | :confirmation | - | +| confirmation | - | :confirmation | attribute | | acceptance | - | :accepted | - | | presence | - | :blank | - | | absence | - | :present | - | @@ -829,6 +829,7 @@ So, for example, instead of the default error message `"cannot be blank"` you co | numericality | :equal_to | :equal_to | count | | numericality | :less_than | :less_than | count | | numericality | :less_than_or_equal_to | :less_than_or_equal_to | count | +| numericality | :other_than | :other_than | count | | numericality | :only_integer | :not_an_integer | - | | numericality | :odd | :odd | - | | numericality | :even | :even | - | -- cgit v1.2.3 From 01c1667b977be4794fe0cf5f2d2b0289a32f4825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 21 Jan 2015 13:12:24 -0200 Subject: Fix test case class in the testing guide [ci skip] --- guides/source/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/testing.md b/guides/source/testing.md index 94cfcf12b7..fa55c09c64 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -1201,7 +1201,7 @@ within a model: ```ruby require 'test_helper' -class ProductTest < ActiveSupport::TestCase +class ProductTest < ActiveJob::TestCase test 'billing job scheduling' do assert_enqueued_with(job: BillingJob) do product.charge(account) -- cgit v1.2.3 From 8b18449c27336bb1861292ff1913df31cbe90f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diogo=20Benic=C3=A1?= Date: Wed, 21 Jan 2015 23:52:44 -0200 Subject: Add :formats to options list of render documentation. --- guides/source/layouts_and_rendering.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md index eb3c188d38..69d3f6e86c 100644 --- a/guides/source/layouts_and_rendering.md +++ b/guides/source/layouts_and_rendering.md @@ -316,12 +316,13 @@ NOTE: Unless overridden, your response returned from this render option will be #### Options for `render` -Calls to the `render` method generally accept four options: +Calls to the `render` method generally accept five options: * `:content_type` * `:layout` * `:location` * `:status` +* `:formats` ##### The `:content_type` Option @@ -430,6 +431,15 @@ Rails understands both numeric status codes and the corresponding symbols shown NOTE: If you try to render content along with a non-content status code (100-199, 204, 205 or 304), it will be dropped from the response. +##### The `:formats` Option + +Rails uses the format specified in request (or `:html` by default). You can change this adding the `:formats` option with a symbol or an array: + +```ruby +render formats: :xml +render formats: [:json, :xml] +``` + #### Finding Layouts To find the current layout, Rails first looks for a file in `app/views/layouts` with the same base name as the controller. For example, rendering actions from the `PhotosController` class will use `app/views/layouts/photos.html.erb` (or `app/views/layouts/photos.builder`). If there is no such controller-specific layout, Rails will use `app/views/layouts/application.html.erb` or `app/views/layouts/application.builder`. If there is no `.erb` layout, Rails will use a `.builder` layout if one exists. Rails also provides several ways to more precisely assign specific layouts to individual controllers and actions. -- cgit v1.2.3 From fce9c4e5e1ecb31cff2ca43a04fbe332816c3c45 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Thu, 22 Jan 2015 22:56:41 +0900 Subject: fix regexp for validate an integer in guides [ci skip] --- guides/source/active_record_validations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/active_record_validations.md b/guides/source/active_record_validations.md index 84925072f2..67cc6a4db3 100644 --- a/guides/source/active_record_validations.md +++ b/guides/source/active_record_validations.md @@ -470,7 +470,7 @@ point number. To specify that only integral numbers are allowed set If you set `:only_integer` to `true`, then it will use the ```ruby -/\A[+-]?\d+\Z/ +/\A[+-]?\d+\z/ ``` regular expression to validate the attribute's value. Otherwise, it will try to -- cgit v1.2.3 From 4e02dcc2521dc74e486faec291684b30565041dc Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Fri, 23 Jan 2015 11:21:42 +0100 Subject: constants guide: make assumption explicit in an example [closes #18465] [ci skip] --- guides/source/autoloading_and_reloading_constants.md | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'guides/source') diff --git a/guides/source/autoloading_and_reloading_constants.md b/guides/source/autoloading_and_reloading_constants.md index c4fac1cff5..202dc601a7 100644 --- a/guides/source/autoloading_and_reloading_constants.md +++ b/guides/source/autoloading_and_reloading_constants.md @@ -114,6 +114,16 @@ certain nesting does not necessarily correlate with the namespaces at the spot. Even more, they are totally independent, take for instance ```ruby +module X + module Y + end +end + +module A + module B + end +end + module X::Y module A::B # (3) -- cgit v1.2.3 From 419d259f6330cda5b744072735b697b93d7b509f Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sat, 24 Jan 2015 22:50:08 +0900 Subject: [ci skip] Fix what is pushed to nesting about eval family --- guides/source/autoloading_and_reloading_constants.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'guides/source') diff --git a/guides/source/autoloading_and_reloading_constants.md b/guides/source/autoloading_and_reloading_constants.md index 202dc601a7..51c46d707c 100644 --- a/guides/source/autoloading_and_reloading_constants.md +++ b/guides/source/autoloading_and_reloading_constants.md @@ -151,9 +151,10 @@ executed, and popped after it. * A singleton class opened with `class << object` gets pushed, and popped later. -* When any of the `*_eval` family of methods is called using a string argument, +* When `instance_eval` is called using a string argument, the singleton class of the receiver is pushed to the nesting of the eval'ed -code. +code. When `class_eval` or `module_eval` is called using a string argument, +the receiver is pushed to the nesting of the eval'ed code. * The nesting at the top-level of code interpreted by `Kernel#load` is empty unless the `load` call receives a true value as second argument, in which case -- cgit v1.2.3 From eed34e2251fbaa03d86402f7d80ecc3f8a62fb51 Mon Sep 17 00:00:00 2001 From: Bryan Bibat Date: Sun, 25 Jan 2015 14:02:54 +0800 Subject: Add tip for running binstubs on Windows [ci skip] The default command prompt under Windows doesn't run binstubs correctly while PowerShell needs to find the location of the Ruby interpreter for it to work properly. Passing the binstubs manually to the interpreter solves this problem. --- guides/source/getting_started.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'guides/source') diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 5945d48e98..a976969dae 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -193,6 +193,9 @@ following in the `blog` directory: $ bin/rails server ``` +TIP: If you are using Windows, you have to pass the scripts under the `bin` +folder directly to the Ruby interpreter e.g. `ruby bin\rails server`. + TIP: Compiling CoffeeScript and JavaScript asset compression requires you have a JavaScript runtime available on your system, in the absence of a runtime you will see an `execjs` error during asset compilation. -- cgit v1.2.3 From 9373ca2808a001857a4914d1358adfd057190677 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Sun, 25 Jan 2015 12:16:32 +0100 Subject: remove trailing whitespace. [ci skip] --- guides/source/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index a976969dae..31f2d2ed2f 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -193,7 +193,7 @@ following in the `blog` directory: $ bin/rails server ``` -TIP: If you are using Windows, you have to pass the scripts under the `bin` +TIP: If you are using Windows, you have to pass the scripts under the `bin` folder directly to the Ruby interpreter e.g. `ruby bin\rails server`. TIP: Compiling CoffeeScript and JavaScript asset compression requires you -- cgit v1.2.3 From d5d9e0af3f72340712ab36467c5edc46db43b9c4 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Tue, 27 Jan 2015 13:16:46 -0200 Subject: Fix typo on guide name [ci skip] --- guides/source/documents.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/documents.yaml b/guides/source/documents.yaml index 67032a31f5..7ae3640937 100644 --- a/guides/source/documents.yaml +++ b/guides/source/documents.yaml @@ -33,7 +33,7 @@ url: active_record_querying.html description: This guide covers the database query interface provided by Active Record. - - name: Active Model basics + name: Active Model Basics url: active_model_basics.html description: This guide covers the use of model classes without Active Record. work_in_progress: true -- cgit v1.2.3 From baf14ae513337cb185acf865e93dfc48f3aabf6a Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Sun, 4 Jan 2015 10:35:06 +0100 Subject: Switch to kwargs in ActionController::TestCase and ActionDispatch::Integration Non-kwargs requests are deprecated now. Guides are updated as well. `post url, nil, nil, { a: 'b' }` doesn't make sense. `post url, params: { y: x }, session: { a: 'b' }` would be an explicit way to do the same --- guides/source/testing.md | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) (limited to 'guides/source') diff --git a/guides/source/testing.md b/guides/source/testing.md index fa55c09c64..50892dd5e2 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -480,21 +480,28 @@ In the `test_should_get_index` test, Rails simulates a request on the action cal The `get` method kicks off the web request and populates the results into the response. It accepts 4 arguments: -* The action of the controller you are requesting. This can be in the form of a string or a symbol. -* An optional hash of request parameters to pass into the action (eg. query string parameters or article variables). -* An optional hash of session variables to pass along with the request. -* An optional hash of flash values. +* The action of the controller you are requesting. + This can be in the form of a string or a symbol. + +* `params:` option with a hash of request parameters to pass into the action + (e.g. query string parameters or article variables). + +* `session:` option with a hash of session variables to pass along with the request. + +* `flash:` option with a hash of flash values. + +All the keyword arguments are optional. Example: Calling the `:show` action, passing an `id` of 12 as the `params` and setting a `user_id` of 5 in the session: ```ruby -get(:show, {'id' => "12"}, {'user_id' => 5}) +get(:show, params: {'id' => "12"}, session: {'user_id' => 5}) ``` Another example: Calling the `:view` action, passing an `id` of 12 as the `params`, this time with no session, but with a flash message. ```ruby -get(:view, {'id' => '12'}, nil, {'message' => 'booya!'}) +get(:view, params: {'id' => '12'}, flash: {'message' => 'booya!'}) ``` NOTE: If you try running `test_should_create_article` test from `articles_controller_test.rb` it will fail on account of the newly added model level validation and rightly so. @@ -504,7 +511,7 @@ Let us modify `test_should_create_article` test in `articles_controller_test.rb` ```ruby test "should create article" do assert_difference('Article.count') do - post :create, article: {title: 'Some title'} + post :create, params: { article: {title: 'Some title'} } end assert_redirected_to article_path(assigns(:article)) @@ -534,7 +541,7 @@ NOTE: Functional tests do not verify whether the specified request type is accep ```ruby test "ajax request responds with no layout" do - xhr :get, :show, id: articles(:first).id + xhr :get, :show, params: { id: articles(:first).id } assert_template :index assert_template layout: nil @@ -638,7 +645,7 @@ Let's start by adding this assertion to our `test_should_create_article` test: ```ruby test "should create article" do assert_difference('Article.count') do - post :create, article: {title: 'Some title'} + post :create, params: { article: {title: 'Some title'} } end assert_redirected_to article_path(assigns(:article)) @@ -708,7 +715,7 @@ Let's write a test for the `:show` action: ```ruby test "should show article" do article = articles(:one) - get :show, id: article.id + get :show, params: { id: article.id } assert_response :success end ``` @@ -721,7 +728,7 @@ How about deleting an existing Article? test "should destroy article" do article = articles(:one) assert_difference('Article.count', -1) do - delete :destroy, id: article.id + delete :destroy, params: { id: article.id } end assert_redirected_to articles_path @@ -733,7 +740,7 @@ We can also add a test for updating an existing Article. ```ruby test "should update article" do article = articles(:one) - patch :update, id: article.id, article: {title: "updated"} + patch :update, params: { id: article.id, article: {title: "updated"} } assert_redirected_to article_path(assigns(:article)) end ``` @@ -759,20 +766,20 @@ class ArticlesControllerTest < ActionController::TestCase test "should show article" do # Reuse the @article instance variable from setup - get :show, id: @article.id + get :show, params: { id: @article.id } assert_response :success end test "should destroy article" do assert_difference('Article.count', -1) do - delete :destroy, id: @article.id + delete :destroy, params: { id: @article.id } end assert_redirected_to articles_path end test "should update article" do - patch :update, id: @article.id, article: {title: "updated"} + patch :update, params: { id: @article.id, article: {title: "updated"} } assert_redirected_to article_path(assigns(:article)) end end @@ -1026,7 +1033,8 @@ test "can create an article" do assert_response :success assert_template "articles/new", partial: "articles/_form" - post "/articles", article: {title: "can create", body: "article successfully."} + post "/articles", + params: { article: {title: "can create", body: "article successfully."} } assert_response :redirect follow_redirect! assert_response :success @@ -1042,7 +1050,8 @@ We start by calling the `:new` action on our Articles controller. This response After this we make a post request to the `:create` action of our Articles controller: ```ruby -post "/articles", article: {title: "can create", body: "article successfully."} +post "/articles", + params: { article: {title: "can create", body: "article successfully."} } assert_response :redirect follow_redirect! ``` @@ -1147,7 +1156,7 @@ require 'test_helper' class UserControllerTest < ActionController::TestCase test "invite friend" do assert_difference 'ActionMailer::Base.deliveries.size', +1 do - post :invite_friend, email: 'friend@example.com' + post :invite_friend, params: { email: 'friend@example.com' } end invite_email = ActionMailer::Base.deliveries.last -- cgit v1.2.3 From 7814f901e1ec0cc3228914f60bd340922f98d94f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 29 Jan 2015 12:19:21 -0200 Subject: Use fixed fonts only in the name of the parameter --- guides/source/testing.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'guides/source') diff --git a/guides/source/testing.md b/guides/source/testing.md index 50892dd5e2..228b8d08fa 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -483,12 +483,12 @@ The `get` method kicks off the web request and populates the results into the re * The action of the controller you are requesting. This can be in the form of a string or a symbol. -* `params:` option with a hash of request parameters to pass into the action +* `params`: option with a hash of request parameters to pass into the action (e.g. query string parameters or article variables). -* `session:` option with a hash of session variables to pass along with the request. +* `session`: option with a hash of session variables to pass along with the request. -* `flash:` option with a hash of flash values. +* `flash`: option with a hash of flash values. All the keyword arguments are optional. -- cgit v1.2.3 From bb6fe7e73a96ac6a9130ed2a68a606ed5f5fb881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 29 Jan 2015 12:19:41 -0200 Subject: Consistent usage of spaces in hashes across our codebase --- guides/source/testing.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'guides/source') diff --git a/guides/source/testing.md b/guides/source/testing.md index 228b8d08fa..a083b3f981 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -495,13 +495,13 @@ All the keyword arguments are optional. Example: Calling the `:show` action, passing an `id` of 12 as the `params` and setting a `user_id` of 5 in the session: ```ruby -get(:show, params: {'id' => "12"}, session: {'user_id' => 5}) +get(:show, params: { 'id' => "12" }, session: { 'user_id' => 5 }) ``` Another example: Calling the `:view` action, passing an `id` of 12 as the `params`, this time with no session, but with a flash message. ```ruby -get(:view, params: {'id' => '12'}, flash: {'message' => 'booya!'}) +get(:view, params: { 'id' => '12' }, flash: { 'message' => 'booya!' }) ``` NOTE: If you try running `test_should_create_article` test from `articles_controller_test.rb` it will fail on account of the newly added model level validation and rightly so. @@ -511,7 +511,7 @@ Let us modify `test_should_create_article` test in `articles_controller_test.rb` ```ruby test "should create article" do assert_difference('Article.count') do - post :create, params: { article: {title: 'Some title'} } + post :create, params: { article: { title: 'Some title' } } end assert_redirected_to article_path(assigns(:article)) @@ -645,7 +645,7 @@ Let's start by adding this assertion to our `test_should_create_article` test: ```ruby test "should create article" do assert_difference('Article.count') do - post :create, params: { article: {title: 'Some title'} } + post :create, params: { article: { title: 'Some title' } } end assert_redirected_to article_path(assigns(:article)) @@ -740,7 +740,7 @@ We can also add a test for updating an existing Article. ```ruby test "should update article" do article = articles(:one) - patch :update, params: { id: article.id, article: {title: "updated"} } + patch :update, params: { id: article.id, article: { title: "updated" } } assert_redirected_to article_path(assigns(:article)) end ``` @@ -779,7 +779,7 @@ class ArticlesControllerTest < ActionController::TestCase end test "should update article" do - patch :update, params: { id: @article.id, article: {title: "updated"} } + patch :update, params: { id: @article.id, article: { title: "updated" } } assert_redirected_to article_path(assigns(:article)) end end @@ -1034,7 +1034,7 @@ test "can create an article" do assert_template "articles/new", partial: "articles/_form" post "/articles", - params: { article: {title: "can create", body: "article successfully."} } + params: { article: { title: "can create", body: "article successfully." } } assert_response :redirect follow_redirect! assert_response :success @@ -1051,7 +1051,7 @@ After this we make a post request to the `:create` action of our Articles contro ```ruby post "/articles", - params: { article: {title: "can create", body: "article successfully."} } + params: { article: { title: "can create", body: "article successfully." } } assert_response :redirect follow_redirect! ``` -- cgit v1.2.3 From 552e9e2299286c97cfa3568cea69e7decd2ff848 Mon Sep 17 00:00:00 2001 From: Brian Morearty Date: Thu, 29 Jan 2015 13:34:44 -0800 Subject: Doc: run bundle update after cloning Rails. --- guides/source/contributing_to_ruby_on_rails.md | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'guides/source') diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index 7381521658..e06706d750 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -173,6 +173,14 @@ $ git checkout -b my_new_branch It doesn't matter much what name you use, because this branch will only exist on your local computer and your personal repository on GitHub. It won't be part of the Rails Git repository. +### Bundle Update + +Update and install the required gems. + +```bash +$ bundle update +``` + ### Running an Application Against Your Local Branch In case you need a dummy Rails app to test changes, the `--dev` flag of `rails new` generates an application that uses your local branch: -- cgit v1.2.3 From 3f11bc00d76dc323a5699762e31138924b24e495 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 29 Jan 2015 20:37:38 -0200 Subject: Improvements about schema dumping [ci skip] --- guides/source/active_record_migrations.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'guides/source') diff --git a/guides/source/active_record_migrations.md b/guides/source/active_record_migrations.md index 97cabc1728..b8db21a989 100644 --- a/guides/source/active_record_migrations.md +++ b/guides/source/active_record_migrations.md @@ -479,7 +479,8 @@ Rails will generate a name for every foreign key starting with There is a `:name` option to specify a different name if needed. NOTE: Active Record only supports single column foreign keys. `execute` and -`structure.sql` are required to use composite foreign keys. +`structure.sql` are required to use composite foreign keys. See +[Schema Dumping and You](#schema-dumping-and-you). Removing a foreign key is easy as well: @@ -695,6 +696,10 @@ of `create_table` and `reversible`, replacing `create_table` by `drop_table`, and finally replacing `up` by `down` and vice-versa. This is all taken care of by `revert`. +NOTE: If you want to add check constraints like in the examples above, +you will have to use `structure.sql` as dump method. See +[Schema Dumping and You](#schema-dumping-and-you). + Running Migrations ------------------ @@ -943,10 +948,10 @@ that Active Record supports. This could be very useful if you were to distribute an application that is able to run against multiple databases. There is however a trade-off: `db/schema.rb` cannot express database specific -items such as triggers, or stored procedures. While in a migration you can -execute custom SQL statements, the schema dumper cannot reconstitute those -statements from the database. If you are using features like this, then you -should set the schema format to `:sql`. +items such as triggers, stored procedures or check constraints. While in a +migration you can execute custom SQL statements, the schema dumper cannot +reconstitute those statements from the database. If you are using features like +this, then you should set the schema format to `:sql`. Instead of using Active Record's schema dumper, the database's structure will be dumped using a tool specific to the database (via the `db:structure:dump` -- cgit v1.2.3 From dc6f5cb0ddfe3901a83fa980b7399f4b43d6a22a Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Thu, 29 Jan 2015 16:46:44 -0800 Subject: Fix grammar in Qualified Constants section New wording is based on the "cref" sentence earlier in the section. [ci skip] --- guides/source/autoloading_and_reloading_constants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/autoloading_and_reloading_constants.md b/guides/source/autoloading_and_reloading_constants.md index 51c46d707c..f0ef03f0ce 100644 --- a/guides/source/autoloading_and_reloading_constants.md +++ b/guides/source/autoloading_and_reloading_constants.md @@ -324,7 +324,7 @@ relative: `::Billing::Invoice`. That would force `Billing` to be looked up only as a top-level constant. `Invoice` on the other hand is qualified by `Billing` and we are going to see -its resolution next. Let's call *parent* to that qualifying class or module +its resolution next. Let's define *parent* to be that qualifying class or module object, that is, `Billing` in the example above. The algorithm for qualified constants goes like this: -- cgit v1.2.3 From 017de712ee55c56f3d9ef9747d276dd0aa43244c Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sat, 31 Jan 2015 14:38:38 -0200 Subject: Add Single Table Inheritance to guides [ci skip] --- guides/source/association_basics.md | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'guides/source') diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index dab885a8fb..8633cc4f10 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -2243,3 +2243,67 @@ Extensions can refer to the internals of the association proxy using these three * `proxy_association.owner` returns the object that the association is a part of. * `proxy_association.reflection` returns the reflection object that describes the association. * `proxy_association.target` returns the associated object for `belongs_to` or `has_one`, or the collection of associated objects for `has_many` or `has_and_belongs_to_many`. + +Single Table Inheritance +------------------------ + +Sometimes, you may want to share fields and behavior between different models. +Let's say we have Car, Motorcycle and Bicycle models. We will want to share +the `color` and `price` fields and some methods for all of them, but having some +specific behavior for each, and separated controllers too. + +Rails makes this quite easy. First, let's generate the base Vehicle model: + +```bash +$ rails generate model vehicle type:string color:string price:decimal{10.2} +``` + +Did you note we are adding a "type" field? Since all models will be saved in a +single database table, Rails will save in this column the name of the model that +is being saved. In our example, this can be "Car", "Motorcycle" or "Bicycle." +STI won't work without a "type" field in the table. + +Next, we will generate the three models that inherit from Vehicle. For this, +we can use the `--parent=PARENT` option, which will generate a model that +inherits from the specified parent and without equivalent migration (since the +table already exists). + +For example, to generate the Car model: + +```bash +$ rails generate model car --parent=Vehicle +``` + +The generated model will look like this: + +```ruby +class Car < Vehicle +end +``` + +This means that all behavior added to Vehicle is available for Car too, as +associations, public methods, etc. + +Creating a car will save it in the `vehicles` table with "Car" as the `type` field: + +```ruby +Car.create color: 'Red', price: 10000 +``` + +will generate the following SQL: + +```sql +INSERT INTO "vehicles" ("type", "color", "price") VALUES ("Car", "Red", 10000) +``` + +Querying car records will just search for vehicles that are cars: + +```ruby +Car.all +``` + +will run a query like: + +```sql +SELECT "vehicles".* FROM "vehicles" WHERE "vehicles"."type" IN ('Car') +``` -- cgit v1.2.3