From eb2d555f5c2e504f9de73dd083f148336f5ffa19 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez=20de=20Dios?=
Date: Tue, 8 Apr 2014 20:59:28 +0200
Subject: Update debugging guide to use byebug
---
guides/source/debugging_rails_applications.md | 423 +++++++++++++++-----------
1 file changed, 246 insertions(+), 177 deletions(-)
(limited to 'guides')
diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md
index 0e10d1b697..2357399900 100644
--- a/guides/source/debugging_rails_applications.md
+++ b/guides/source/debugging_rails_applications.md
@@ -240,130 +240,109 @@ The contents of the block, and therefore the string interpolation, is only
evaluated if debug is enabled. This performance savings is only really
noticeable with large amounts of logging, but it's a good practice to employ.
-Debugging with the `debugger` gem
+Debugging with the `byebug` gem
---------------------------------
-When your code is behaving in unexpected ways, you can try printing to logs or the console to diagnose the problem. Unfortunately, there are times when this sort of error tracking is not effective in finding the root cause of a problem. When you actually need to journey into your running source code, the debugger is your best companion.
+When your code is behaving in unexpected ways, you can try printing to logs or
+the console to diagnose the problem. Unfortunately, there are times when this
+sort of error tracking is not effective in finding the root cause of a problem.
+When you actually need to journey into your running source code, the debugger
+is your best companion.
-The debugger can also help you if you want to learn about the Rails source code but don't know where to start. Just debug any request to your application and use this guide to learn how to move from the code you have written deeper into Rails code.
+The debugger can also help you if you want to learn about the Rails source code
+but don't know where to start. Just debug any request to your application and
+use this guide to learn how to move from the code you have written deeper into
+Rails code.
### Setup
-You can use the `debugger` gem to set breakpoints and step through live code in Rails. To install it, just run:
+You can use the `byebug` gem to set breakpoints and step through live code in
+Rails. To install it, just run:
```bash
-$ gem install debugger
+$ gem install byebug
```
-Rails has had built-in support for debugging since Rails 2.0. Inside any Rails application you can invoke the debugger by calling the `debugger` method.
+Inside any Rails application you can then invoke the debugger by calling the
+`byebug` method.
Here's an example:
```ruby
class PeopleController < ApplicationController
def new
- debugger
+ byebug
@person = Person.new
end
end
```
-If you see this message in the console or logs:
-
-```
-***** Debugger requested, but was not available: Start server with --debugger to enable *****
-```
-
-Make sure you have started your web server with the option `--debugger`:
-
-```bash
-$ rails server --debugger
-=> Booting WEBrick
-=> Rails 4.0.0 application starting on http://0.0.0.0:3000
-=> Debugger enabled
-...
-```
-
-TIP: In development mode, you can dynamically `require \'debugger\'` instead of restarting the server, even if it was started without `--debugger`.
-
### The Shell
-As soon as your application calls the `debugger` method, the debugger will be started in a debugger shell inside the terminal window where you launched your application server, and you will be placed at the debugger's prompt `(rdb:n)`. The _n_ is the thread number. The prompt will also show you the next line of code that is waiting to run.
-
-If you got there by a browser request, the browser tab containing the request will be hung until the debugger has finished and the trace has finished processing the entire request.
-
-For example:
-
-```bash
-@posts = Post.all
-(rdb:7)
-```
-
-Now it's time to explore and dig into your application. A good place to start is by asking the debugger for help. Type: `help`
-
-```
-(rdb:7) help
-ruby-debug help v0.10.2
-Type 'help ' for help on a specific command
-
-Available commands:
-backtrace delete enable help next quit show trace
-break disable eval info p reload source undisplay
-catch display exit irb pp restart step up
-condition down finish list ps save thread var
-continue edit frame method putl set tmate where
-```
-
-TIP: To view the help menu for any command use `help ` at the debugger prompt. For example: _`help var`_
-
-The next command to learn is one of the most useful: `list`. You can abbreviate any debugging command by supplying just enough letters to distinguish them from other commands, so you can also use `l` for the `list` command.
-
-This command shows you where you are in the code by printing 10 lines centered around the current line; the current line in this particular case is line 6 and is marked by `=>`.
+As soon as your application calls the `byebug` method, the debugger will be
+started in a debugger shell inside the terminal window where you launched your
+application server, and you will be placed at the debugger's prompt `(byebug)`.
+Before the prompt, the code around the line that is about to be run will be
+shown and the current line is marked by '=>'. Like this:
```
-(rdb:7) list
[1, 10] in /PathTo/project/app/controllers/posts_controller.rb
1 class PostsController < ApplicationController
2 # GET /posts
3 # GET /posts.json
4 def index
- 5 debugger
+ 5 byebug
=> 6 @posts = Post.all
7
8 respond_to do |format|
9 format.html # index.html.erb
10 format.json { render json: @posts }
+(byebug)
```
-If you repeat the `list` command, this time using just `l`, the next ten lines of the file will be printed out.
+If you got there by a browser request, the browser tab containing the request
+will be hung until the debugger has finished and the trace has finished
+processing the entire request.
+For example:
+
+```bash
+@posts = Post.all
+(rdb:7)
```
-(rdb:7) l
-[11, 20] in /PathTo/project/app/controllers/posts_controller.rb
- 11 end
- 12 end
- 13
- 14 # GET /posts/1
- 15 # GET /posts/1.json
- 16 def show
- 17 @post = Post.find(params[:id])
- 18
- 19 respond_to do |format|
- 20 format.html # show.html.erb
+
+Now it's time to explore and dig into your application. A good place to start is
+by asking the debugger for help. Type: `help`
+
```
+(byebug) help
+byebug 2.6.0
-And so on until the end of the current file. When the end of file is reached, the `list` command will start again from the beginning of the file and continue again up to the end, treating the file as a circular buffer.
+Type 'help ' for help on a specific command
-On the other hand, to see the previous ten lines you should type `list-` (or `l-`)
+Available commands:
+backtrace delete enable help list pry next restart source up
+break disable eval info method ps save step var
+catch display exit interrupt next putl set thread
+condition down finish irb p quit show trace
+continue edit frame kill pp reload skip undisplay
+```
+
+TIP: To view the help menu for any command use `help ` at the
+debugger prompt. For example: _`help list`_. You can abbreviate any debugging
+command by supplying just enough letters to distinguish them from other
+commands, so you can also use `l` for the `list` command, for example.
+
+To see the previous ten lines you should type `list-` (or `l-`)
```
-(rdb:7) l-
+(byebug) l-
[1, 10] in /PathTo/project/app/controllers/posts_controller.rb
1 class PostsController < ApplicationController
2 # GET /posts
3 # GET /posts.json
4 def index
- 5 debugger
+ 5 byebug
6 @posts = Post.all
7
8 respond_to do |format|
@@ -371,17 +350,18 @@ On the other hand, to see the previous ten lines you should type `list-` (or `l-
10 format.json { render json: @posts }
```
-This way you can move inside the file, being able to see the code above and over the line you added the `debugger`.
-Finally, to see where you are in the code again you can type `list=`
+This way you can move inside the file, being able to see the code above and over
+the line you added the `byebug` call. Finally, to see where you are in the code
+again you can type `list=`
```
-(rdb:7) list=
+(byebug) list=
[1, 10] in /PathTo/project/app/controllers/posts_controller.rb
1 class PostsController < ApplicationController
2 # GET /posts
3 # GET /posts.json
4 def index
- 5 debugger
+ 5 byebug
=> 6 @posts = Post.all
7
8 respond_to do |format|
@@ -391,14 +371,22 @@ Finally, to see where you are in the code again you can type `list=`
### The Context
-When you start debugging your application, you will be placed in different contexts as you go through the different parts of the stack.
+When you start debugging your application, you will be placed in different
+contexts as you go through the different parts of the stack.
-The debugger creates a context when a stopping point or an event is reached. The context has information about the suspended program which enables a debugger to inspect the frame stack, evaluate variables from the perspective of the debugged program, and contains information about the place where the debugged program is stopped.
+The debugger creates a context when a stopping point or an event is reached. The
+context has information about the suspended program which enables the debugger
+to inspect the frame stack, evaluate variables from the perspective of the
+debugged program, and contains information about the place where the debugged
+program is stopped.
-At any time you can call the `backtrace` command (or its alias `where`) to print the backtrace of the application. This can be very helpful to know how you got where you are. If you ever wondered about how you got somewhere in your code, then `backtrace` will supply the answer.
+At any time you can call the `backtrace` command (or its alias `where`) to print
+the backtrace of the application. This can be very helpful to know how you got
+where you are. If you ever wondered about how you got somewhere in your code,
+then `backtrace` will supply the answer.
```
-(rdb:5) where
+(byebug) where
#0 PostsController.index
at line /PathTo/project/app/controllers/posts_controller.rb:6
#1 Kernel.send
@@ -410,46 +398,64 @@ At any time you can call the `backtrace` command (or its alias `where`) to print
...
```
-You move anywhere you want in this trace (thus changing the context) by using the `frame _n_` command, where _n_ is the specified frame number.
+You move anywhere you want in this trace (thus changing the context) by using
+the `frame _n_` command, where _n_ is the specified frame number.
```
-(rdb:5) frame 2
+(byebug) frame 2
#2 ActionController::Base.perform_action_without_filters
at line /PathTo/project/vendor/rails/actionpack/lib/action_controller/base.rb:1175
```
-The available variables are the same as if you were running the code line by line. After all, that's what debugging is.
+The available variables are the same as if you were running the code line by
+line. After all, that's what debugging is.
-Moving up and down the stack frame: You can use `up [n]` (`u` for abbreviated) and `down [n]` commands in order to change the context _n_ frames up or down the stack respectively. _n_ defaults to one. Up in this case is towards higher-numbered stack frames, and down is towards lower-numbered stack frames.
+Moving up and down the stack frame: You can use `up [n]` (`u` for abbreviated)
+and `down [n]` commands in order to change the context _n_ frames up or down the
+stack respectively. _n_ defaults to one. Up in this case is towards
+higher-numbered stack frames, and down is towards lower-numbered stack frames.
### Threads
-The debugger can list, stop, resume and switch between running threads by using the command `thread` (or the abbreviated `th`). This command has a handful of options:
+The debugger can list, stop, resume and switch between running threads by using
+the command `thread` (or the abbreviated `th`). This command has a handful of
+options:
* `thread` shows the current thread.
-* `thread list` is used to list all threads and their statuses. The plus + character and the number indicates the current thread of execution.
+* `thread list` is used to list all threads and their statuses. The plus +
+character and the number indicates the current thread of execution.
* `thread stop _n_` stop thread _n_.
* `thread resume _n_` resumes thread _n_.
* `thread switch _n_` switches the current thread context to _n_.
-This command is very helpful, among other occasions, when you are debugging concurrent threads and need to verify that there are no race conditions in your code.
+This command is very helpful, among other occasions, when you are debugging
+concurrent threads and need to verify that there are no race conditions in your
+code.
### Inspecting Variables
-Any expression can be evaluated in the current context. To evaluate an expression, just type it!
+Any expression can be evaluated in the current context. To evaluate an
+expression, just type it!
-This example shows how you can print the instance_variables defined within the current context:
+This example shows how you can print the instance_variables defined within the
+current context:
```
@posts = Post.all
-(rdb:11) instance_variables
-["@_response", "@action_name", "@url", "@_session", "@_cookies", "@performed_render", "@_flash", "@template", "@_params", "@before_filter_chain_aborted", "@request_origin", "@_headers", "@performed_redirect", "@_request"]
+(byebug) instance_variables
+["@_response", "@action_name", "@url", "@_session", "@_cookies",
+ "@performed_render", "@_flash", "@template", "@_params",
+ "@before_filter_chain_aborted", "@request_origin", "@_headers",
+ "@performed_redirect", "@_request"]
```
-As you may have figured out, all of the variables that you can access from a controller are displayed. This list is dynamically updated as you execute code. For example, run the next line using `next` (you'll learn more about this command later in this guide).
+As you may have figured out, all of the variables that you can access from a
+controller are displayed. This list is dynamically updated as you execute code.
+For example, run the next line using `next` (you'll learn more about this
+command later in this guide).
```
-(rdb:11) next
+(byebug) next
Processing PostsController#index (for 127.0.0.1 at 2008-09-04 19:51:34) [GET]
Session ID: BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7AA==--b16e91b992453a8cc201694d660147bba8b0fd0e
Parameters: {"action"=>"index", "controller"=>"posts"}
@@ -460,64 +466,80 @@ respond_to do |format|
And then ask again for the instance_variables:
```
-(rdb:11) instance_variables.include? "@posts"
+(byebug) instance_variables.include? "@posts"
true
```
-Now `@posts` is included in the instance variables, because the line defining it was executed.
+Now `@posts` is included in the instance variables, because the line defining it
+was executed.
-TIP: You can also step into **irb** mode with the command `irb` (of course!). This way an irb session will be started within the context you invoked it. But be warned: this is an experimental feature.
+TIP: You can also step into **irb** mode with the command `irb` (of course!).
+This way an irb session will be started within the context you invoked it. But
+be warned: this is an experimental feature.
The `var` method is the most convenient way to show variables and their values:
```
var
-(rdb:1) v[ar] const
<% else %>
- These are the new guides for Rails 4.0 based on <%= @version %>.
+ These are the new guides for Rails 4.1 based on <%= @version %>.
These guides are designed to make you immediately productive with Rails, and to help you understand how all of the pieces fit together.
--
cgit v1.2.3
From 73bfb510119e7552378949d635164010e3d5abe2 Mon Sep 17 00:00:00 2001
From: Vipul A M
Date: Sat, 12 Apr 2014 12:46:04 +0530
Subject: Change links to 37signals and svn blog to point to new destinations.
[ci skip]
---
guides/source/caching_with_rails.md | 4 ++--
guides/source/credits.html.erb | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
(limited to 'guides')
diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md
index e898d75d1a..b6423dd44e 100644
--- a/guides/source/caching_with_rails.md
+++ b/guides/source/caching_with_rails.md
@@ -30,13 +30,13 @@ config.action_controller.perform_caching = true
Page caching is a Rails mechanism which allows the request for a generated page to be fulfilled by the webserver (i.e. Apache or nginx), without ever having to go through the Rails stack at all. Obviously, this is super-fast. Unfortunately, it can't be applied to every situation (such as pages that need authentication) and since the webserver is literally just serving a file from the filesystem, cache expiration is an issue that needs to be dealt with.
-INFO: Page Caching has been removed from Rails 4. See the [actionpack-page_caching gem](https://github.com/rails/actionpack-page_caching). See [DHH's key-based cache expiration overview](http://37signals.com/svn/posts/3113-how-key-based-cache-expiration-works) for the newly-preferred method.
+INFO: Page Caching has been removed from Rails 4. See the [actionpack-page_caching gem](https://github.com/rails/actionpack-page_caching). See [DHH's key-based cache expiration overview](http://signalvnoise.com/posts/3113-how-key-based-cache-expiration-works) for the newly-preferred method.
### Action Caching
Page Caching cannot be used for actions that have before filters - for example, pages that require authentication. This is where Action Caching comes in. Action Caching works like Page Caching except the incoming web request hits the Rails stack so that before filters can be run on it before the cache is served. This allows authentication and other restrictions to be run while still serving the result of the output from a cached copy.
-INFO: Action Caching has been removed from Rails 4. See the [actionpack-action_caching gem](https://github.com/rails/actionpack-action_caching). See [DHH's key-based cache expiration overview](http://37signals.com/svn/posts/3113-how-key-based-cache-expiration-works) for the newly-preferred method.
+INFO: Action Caching has been removed from Rails 4. See the [actionpack-action_caching gem](https://github.com/rails/actionpack-action_caching). See [DHH's key-based cache expiration overview](http://signalvnoise.com/posts/3113-how-key-based-cache-expiration-works) for the newly-preferred method.
### Fragment Caching
diff --git a/guides/source/credits.html.erb b/guides/source/credits.html.erb
index 7c6858fa2c..8767fbecce 100644
--- a/guides/source/credits.html.erb
+++ b/guides/source/credits.html.erb
@@ -64,7 +64,7 @@ Oscar Del Ben is a software engineer at Wi
<% end %>
<%= author('Pratik Naik', 'lifo') do %>
- Pratik Naik is a Ruby on Rails developer at 37signals and also a member of the Rails core team. He maintains a blog at has_many :bugs, :through => :rails and has a semi-active twitter account.
+ Pratik Naik is a Ruby on Rails developer at Basecamp and also a member of the Rails core team. He maintains a blog at has_many :bugs, :through => :rails and has a semi-active twitter account.
<% end %>
<%= author('Emilio Tagua', 'miloops') do %>
--
cgit v1.2.3
From 80d0dd53caeb55dffcbf3e86b3707d170899f035 Mon Sep 17 00:00:00 2001
From: Robin Dupret
Date: Sat, 12 Apr 2014 20:10:15 +0200
Subject: Fix a few typos [ci skip]
This is a follow up to 545afc15.
---
guides/source/debugging_rails_applications.md | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
(limited to 'guides')
diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md
index 042ffa7d8d..b067d9efb7 100644
--- a/guides/source/debugging_rails_applications.md
+++ b/guides/source/debugging_rails_applications.md
@@ -210,7 +210,7 @@ logger.tagged("BCX") { logger.tagged("Jason") { logger.info "Stuff" } } # Logs "
```
### Impact of Logs on Performance
-Logging will always have a small impact on performance of your rails app,
+Logging will always have a small impact on performance of your rails app,
particularly when logging to disk.However, there are a few subtleties:
Using the `:debug` level will have a greater performance penalty than `:fatal`,
@@ -224,20 +224,20 @@ Another potential pitfall is that if you have many calls to `Logger` like this
logger.debug "Person attributes hash: #{@person.attributes.inspect}"
```
-In the above example, There will be a performance impact even if the allowed
-output level doesn't include debug. The reason is that Ruby has to evaluate
-these strings, which includes instantiating the somewhat heavy `String` object
+In the above example, There will be a performance impact even if the allowed
+output level doesn't include debug. The reason is that Ruby has to evaluate
+these strings, which includes instantiating the somewhat heavy `String` object
and interpolating the variables, and which takes time.
-Therefore, it's recommended to pass blocks to the logger methods, as these are
-only evaluated if the output level is the same or included in the allowed level
+Therefore, it's recommended to pass blocks to the logger methods, as these are
+only evaluated if the output level is the same or included in the allowed level
(i.e. lazy loading). The same code rewritten would be:
```ruby
logger.debug {"Person attributes hash: #{@person.attributes.inspect}"}
```
-The contents of the block, and therefore the string interpolation, is only
-evaluated if debug is enabled. This performance savings is only really
+The contents of the block, and therefore the string interpolation, is only
+evaluated if debug is enabled. This performance savings is only really
noticeable with large amounts of logging, but it's a good practice to employ.
Debugging with the `byebug` gem
@@ -380,7 +380,7 @@ To see the previous ten lines you should type `list-` (or `l-`)
```
This way you can move inside the file, being able to see the code above and over
-the line where you added the `byebug` call. Finally, to see where you are in
+the line where you added the `byebug` call. Finally, to see where you are in
the code again you can type `list=`
```
@@ -464,7 +464,7 @@ towards lower-numbered stack frames.
### Threads
The debugger can list, stop, resume and switch between running threads by using
-the command `thread` (or the abbreviated `th`). This command has a handful of
+the `thread` command (or the abbreviated `th`). This command has a handful of
options:
* `thread` shows the current thread.
@@ -483,7 +483,7 @@ code.
Any expression can be evaluated in the current context. To evaluate an
expression, just type it!
-This example shows how you can print the instance_variables defined within the
+This example shows how you can print the instance variables defined within the
current context:
```
@@ -626,7 +626,7 @@ Processing by PostsController#index as HTML
(byebug)
```
-If we use `next`, we want go deep inside method calls. Instead, byebug will go
+If we use `next`, we want go deep inside method calls. Instead, byebug will go
to the next line within the same context. In this case, this is the last line of
the method, so `byebug` will jump to next next line of the previous frame.
@@ -731,7 +731,7 @@ No breakpoints.
You can also enable or disable breakpoints:
-* `enable breakpoints`: allow a list _breakpoints_ or all of them if no list is
+* `enable breakpoints`: allow a _breakpoints_ list or all of them if no list is
specified, to stop your program. This is the default state when you create a
breakpoint.
* `disable breakpoints`: the _breakpoints_ will have no effect on your program.
--
cgit v1.2.3
From 7782fdcf2b093d977f4cdcba884bcab07aad25ef Mon Sep 17 00:00:00 2001
From: Afshin Mokhtari
Date: Sat, 12 Apr 2014 17:43:23 -0700
Subject: Missing 'are' in note - [ci skip]
This is in the note at the end of Section 2: Controller Naming Convention. [ci skip]
---
guides/source/action_controller_overview.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'guides')
diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md
index 0f46ba8698..d788d13ac9 100644
--- a/guides/source/action_controller_overview.md
+++ b/guides/source/action_controller_overview.md
@@ -34,7 +34,7 @@ The naming convention of controllers in Rails favors pluralization of the last w
Following this convention will allow you to use the default route generators (e.g. `resources`, etc) without needing to qualify each `:path` or `:controller`, and keeps URL and path helpers' usage consistent throughout your application. See [Layouts & Rendering Guide](layouts_and_rendering.html) for more details.
-NOTE: The controller naming convention differs from the naming convention of models, which expected to be named in singular form.
+NOTE: The controller naming convention differs from the naming convention of models, which are expected to be named in singular form.
Methods and Actions
--
cgit v1.2.3
From 2ddbe87e7acc324ce7e0a4784c4d10b79cc49a40 Mon Sep 17 00:00:00 2001
From: Marcel Morgan
Date: Sat, 12 Apr 2014 08:31:00 -0500
Subject: Update documentation to use Rails.application instead
References to ``AppName::Application` removed in favour of ``Rails.application``
as generated with a new rails 4.1 app.
[ci skip]
---
guides/code/getting_started/Rakefile | 2 +-
guides/code/getting_started/config.ru | 2 +-
guides/code/getting_started/config/environment.rb | 2 +-
guides/code/getting_started/config/environments/development.rb | 2 +-
guides/code/getting_started/config/environments/production.rb | 2 +-
guides/code/getting_started/config/environments/test.rb | 2 +-
guides/code/getting_started/config/initializers/secret_token.rb | 2 +-
guides/code/getting_started/config/initializers/session_store.rb | 2 +-
guides/code/getting_started/config/routes.rb | 2 +-
guides/source/action_controller_overview.md | 6 +++---
guides/source/getting_started.md | 2 +-
guides/source/i18n.md | 2 +-
guides/source/initialization.md | 2 +-
guides/source/rails_on_rack.md | 9 ++++-----
guides/source/routing.md | 4 ++--
15 files changed, 21 insertions(+), 22 deletions(-)
(limited to 'guides')
diff --git a/guides/code/getting_started/Rakefile b/guides/code/getting_started/Rakefile
index 05de8bb536..ba6b733dd2 100644
--- a/guides/code/getting_started/Rakefile
+++ b/guides/code/getting_started/Rakefile
@@ -3,4 +3,4 @@
require File.expand_path('../config/application', __FILE__)
-Blog::Application.load_tasks
+Rails.application.load_tasks
diff --git a/guides/code/getting_started/config.ru b/guides/code/getting_started/config.ru
index ddf869e921..5bc2a619e8 100644
--- a/guides/code/getting_started/config.ru
+++ b/guides/code/getting_started/config.ru
@@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
-run Blog::Application
+run Rails.application
diff --git a/guides/code/getting_started/config/environment.rb b/guides/code/getting_started/config/environment.rb
index e7e341c960..ee8d90dc65 100644
--- a/guides/code/getting_started/config/environment.rb
+++ b/guides/code/getting_started/config/environment.rb
@@ -2,4 +2,4 @@
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
-Blog::Application.initialize!
+Rails.application.initialize!
diff --git a/guides/code/getting_started/config/environments/development.rb b/guides/code/getting_started/config/environments/development.rb
index 7e5692b08b..ae9ffe209a 100644
--- a/guides/code/getting_started/config/environments/development.rb
+++ b/guides/code/getting_started/config/environments/development.rb
@@ -1,4 +1,4 @@
-Blog::Application.configure do
+Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
diff --git a/guides/code/getting_started/config/environments/production.rb b/guides/code/getting_started/config/environments/production.rb
index 8c514e065e..c8ae858574 100644
--- a/guides/code/getting_started/config/environments/production.rb
+++ b/guides/code/getting_started/config/environments/production.rb
@@ -1,4 +1,4 @@
-Blog::Application.configure do
+Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
diff --git a/guides/code/getting_started/config/environments/test.rb b/guides/code/getting_started/config/environments/test.rb
index 34ab1530d1..680d0b9e06 100644
--- a/guides/code/getting_started/config/environments/test.rb
+++ b/guides/code/getting_started/config/environments/test.rb
@@ -1,4 +1,4 @@
-Blog::Application.configure do
+Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
diff --git a/guides/code/getting_started/config/initializers/secret_token.rb b/guides/code/getting_started/config/initializers/secret_token.rb
index aaf57731be..c2a549c299 100644
--- a/guides/code/getting_started/config/initializers/secret_token.rb
+++ b/guides/code/getting_started/config/initializers/secret_token.rb
@@ -9,4 +9,4 @@
# Make sure your secret_key_base is kept private
# if you're sharing your code publicly.
-Blog::Application.config.secret_key_base = 'e8aab50cec8a06a75694111a4cbaf6e22fc288ccbc6b268683aae7273043c69b15ca07d10c92a788dd6077a54762cbfcc55f19c3459f7531221b3169f8171a53'
+Rails.application.config.secret_key_base = 'e8aab50cec8a06a75694111a4cbaf6e22fc288ccbc6b268683aae7273043c69b15ca07d10c92a788dd6077a54762cbfcc55f19c3459f7531221b3169f8171a53'
diff --git a/guides/code/getting_started/config/initializers/session_store.rb b/guides/code/getting_started/config/initializers/session_store.rb
index 3b2ca93ab9..1b9fa324d4 100644
--- a/guides/code/getting_started/config/initializers/session_store.rb
+++ b/guides/code/getting_started/config/initializers/session_store.rb
@@ -1,3 +1,3 @@
# Be sure to restart your server when you modify this file.
-Blog::Application.config.session_store :cookie_store, key: '_blog_session'
+Rails.application.config.session_store :cookie_store, key: '_blog_session'
diff --git a/guides/code/getting_started/config/routes.rb b/guides/code/getting_started/config/routes.rb
index 0155b613a3..65d273b58d 100644
--- a/guides/code/getting_started/config/routes.rb
+++ b/guides/code/getting_started/config/routes.rb
@@ -1,4 +1,4 @@
-Blog::Application.routes.draw do
+Rails.application.routes.draw do
resources :posts do
resources :comments
end
diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md
index d788d13ac9..ee2b00aedb 100644
--- a/guides/source/action_controller_overview.md
+++ b/guides/source/action_controller_overview.md
@@ -364,21 +364,21 @@ If you need a different session storage mechanism, you can change it in the `con
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails g active_record:session_migration")
-# YourApp::Application.config.session_store :active_record_store
+# Rails.application.config.session_store :active_record_store
```
Rails sets up a session key (the name of the cookie) when signing the session data. These can also be changed in `config/initializers/session_store.rb`:
```ruby
# Be sure to restart your server when you modify this file.
-YourApp::Application.config.session_store :cookie_store, key: '_your_app_session'
+Rails.application.config.session_store :cookie_store, key: '_your_app_session'
```
You can also pass a `:domain` key and specify the domain name for the cookie:
```ruby
# Be sure to restart your server when you modify this file.
-YourApp::Application.config.session_store :cookie_store, key: '_your_app_session', domain: ".example.com"
+Rails.application.config.session_store :cookie_store, key: '_your_app_session', domain: ".example.com"
```
Rails sets up (for the CookieStore) a secret key used for signing the session data. This can be changed in `config/secrets.yml`
diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md
index c54c9efe94..bafb75c668 100644
--- a/guides/source/getting_started.md
+++ b/guides/source/getting_started.md
@@ -344,7 +344,7 @@ resource. Here's what `config/routes.rb` should look like after the
_article resource_ is declared.
```ruby
-Blog::Application.routes.draw do
+Rails.application.routes.draw do
resources :articles
diff --git a/guides/source/i18n.md b/guides/source/i18n.md
index 6bd033f0de..466ffe7907 100644
--- a/guides/source/i18n.md
+++ b/guides/source/i18n.md
@@ -309,7 +309,7 @@ You most probably have something like this in one of your applications:
```ruby
# config/routes.rb
-Yourapp::Application.routes.draw do
+Rails.application.routes.draw do
root to: "home#index"
end
```
diff --git a/guides/source/initialization.md b/guides/source/initialization.md
index ca5fcbbcbd..77f3615ca0 100644
--- a/guides/source/initialization.md
+++ b/guides/source/initialization.md
@@ -558,7 +558,7 @@ The rest of `config/application.rb` defines the configuration for the
initialized. When `config/application.rb` has finished loading Rails and defined
the application namespace, we go back to `config/environment.rb`,
where the application is initialized. For example, if the application was called
-`Blog`, here we would find `Blog::Application.initialize!`, which is
+`Blog`, here we would find `Rails.application.initialize!`, which is
defined in `rails/application.rb`
### `railties/lib/rails/application.rb`
diff --git a/guides/source/rails_on_rack.md b/guides/source/rails_on_rack.md
index 9c92cf3aea..b1b4c8fa4e 100644
--- a/guides/source/rails_on_rack.md
+++ b/guides/source/rails_on_rack.md
@@ -27,10 +27,9 @@ Rails on Rack
### Rails Application's Rack Object
-`ApplicationName::Application` is the primary Rack application object of a Rails
+`Rails.application` is the primary Rack application object of a Rails
application. Any Rack compliant web server should be using
-`ApplicationName::Application` object to serve a Rails
-application. `Rails.application` refers to the same application object.
+`Rails.application` object to serve a Rails application.
### `rails server`
@@ -141,7 +140,7 @@ use ActionDispatch::ParamsParser
use Rack::Head
use Rack::ConditionalGet
use Rack::ETag
-run MyApp::Application.routes
+run Rails.application.routes
```
The default middlewares shown here (and some others) are each summarized in the [Internal Middlewares](#internal-middleware-stack) section, below.
@@ -201,7 +200,7 @@ use ActionDispatch::Static
use #
use Rack::Runtime
...
-run Blog::Application.routes
+run Rails.application.routes
```
If you want to remove session related middleware, do the following:
diff --git a/guides/source/routing.md b/guides/source/routing.md
index 921658a71e..0783bce442 100644
--- a/guides/source/routing.md
+++ b/guides/source/routing.md
@@ -711,7 +711,7 @@ class BlacklistConstraint
end
end
-TwitterClone::Application.routes.draw do
+Rails.application.routes.draw do
get '*path', to: 'blacklist#index',
constraints: BlacklistConstraint.new
end
@@ -720,7 +720,7 @@ end
You can also specify constraints as a lambda:
```ruby
-TwitterClone::Application.routes.draw do
+Rails.application.routes.draw do
get '*path', to: 'blacklist#index',
constraints: lambda { |request| Blacklist.retrieve_ips.include?(request.remote_ip) }
end
--
cgit v1.2.3
From 982a19edc932caa3d58394b0f7076a191eff5a54 Mon Sep 17 00:00:00 2001
From: Juanito Fatas
Date: Sun, 13 Apr 2014 23:56:59 +0800
Subject: [ci skip] Use plain underscore instead of "\_".
---
guides/source/3_0_release_notes.md | 2 +-
guides/source/3_2_release_notes.md | 2 +-
guides/source/association_basics.md | 2 +-
guides/source/security.md | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
(limited to 'guides')
diff --git a/guides/source/3_0_release_notes.md b/guides/source/3_0_release_notes.md
index dd81ec58f9..2d4be0cda7 100644
--- a/guides/source/3_0_release_notes.md
+++ b/guides/source/3_0_release_notes.md
@@ -294,7 +294,7 @@ NOTE. The old style `map` commands still work as before with a backwards compati
Deprecations
* The catch all route for non-REST applications (`/:controller/:action/:id`) is now commented out.
-* Routes :path\_prefix no longer exists and :name\_prefix now automatically adds "\_" at the end of the given value.
+* Routes `:path_prefix` no longer exists and `:name_prefix` now automatically adds "_" at the end of the given value.
More Information:
* [The Rails 3 Router: Rack it Up](http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up/)
diff --git a/guides/source/3_2_release_notes.md b/guides/source/3_2_release_notes.md
index ce811a583b..cdcde67869 100644
--- a/guides/source/3_2_release_notes.md
+++ b/guides/source/3_2_release_notes.md
@@ -187,7 +187,7 @@ Action Pack
Rails will use `layouts/single_car` when a request comes in `:show` action, and use `layouts/application` (or `layouts/cars`, if exists) when a request comes in for any other actions.
-* `form\_for` is changed to use `#{action}\_#{as}` as the css class and id if `:as` option is provided. Earlier versions used `#{as}\_#{action}`.
+* `form_for` is changed to use `#{action}_#{as}` as the css class and id if `:as` option is provided. Earlier versions used `#{as}_#{action}`.
* `ActionController::ParamsWrapper` on Active Record models now only wrap `attr_accessible` attributes if they were set. If not, only the attributes returned by the class method `attribute_names` will be wrapped. This fixes the wrapping of nested attributes by adding them to `attr_accessible`.
diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md
index 5ec6ae0f21..df38bd7321 100644
--- a/guides/source/association_basics.md
+++ b/guides/source/association_basics.md
@@ -571,7 +571,7 @@ If you create an association some time after you build the underlying model, you
If you create a `has_and_belongs_to_many` association, you need to explicitly create the joining table. Unless the name of the join table is explicitly specified by using the `:join_table` option, Active Record creates the name by using the lexical order of the class names. So a join between customer and order models will give the default join table name of "customers_orders" because "c" outranks "o" in lexical ordering.
-WARNING: The precedence between model names is calculated using the `<` operator for `String`. This means that if the strings are of different lengths, and the strings are equal when compared up to the shortest length, then the longer string is considered of higher lexical precedence than the shorter one. For example, one would expect the tables "paper\_boxes" and "papers" to generate a join table name of "papers\_paper\_boxes" because of the length of the name "paper\_boxes", but it in fact generates a join table name of "paper\_boxes\_papers" (because the underscore '\_' is lexicographically _less_ than 's' in common encodings).
+WARNING: The precedence between model names is calculated using the `<` operator for `String`. This means that if the strings are of different lengths, and the strings are equal when compared up to the shortest length, then the longer string is considered of higher lexical precedence than the shorter one. For example, one would expect the tables "paper_boxes" and "papers" to generate a join table name of "papers_paper_boxes" because of the length of the name "paper_boxes", but it in fact generates a join table name of "paper_boxes_papers" (because the underscore '_' is lexicographically _less_ than 's' in common encodings).
Whatever the name, you must manually generate the join table with an appropriate migration. For example, consider these associations:
diff --git a/guides/source/security.md b/guides/source/security.md
index 9603fb4a4d..15b28664b7 100644
--- a/guides/source/security.md
+++ b/guides/source/security.md
@@ -151,7 +151,7 @@ The most effective countermeasure is to _issue a new session identifier_ and dec
reset_session
```
-If you use the popular RestfulAuthentication plugin for user management, add reset\_session to the SessionsController#create action. Note that this removes any value from the session, _you have to transfer them to the new session_.
+If you use the popular RestfulAuthentication plugin for user management, add reset_session to the SessionsController#create action. Note that this removes any value from the session, _you have to transfer them to the new session_.
Another countermeasure is to _save user-specific properties in the session_, verify them every time a request comes in, and deny access, if the information does not match. Such properties could be the remote IP address or the user agent (the web browser name), though the latter is less user-specific. When saving the IP address, you have to bear in mind that there are Internet service providers or large organizations that put their users behind proxies. _These might change over the course of a session_, so these users will not be able to use your application, or only in a limited way.
@@ -314,7 +314,7 @@ def sanitize_filename(filename)
end
```
-A significant disadvantage of synchronous processing of file uploads (as the attachment\_fu plugin may do with images), is its _vulnerability to denial-of-service attacks_. An attacker can synchronously start image file uploads from many computers which increases the server load and may eventually crash or stall the server.
+A significant disadvantage of synchronous processing of file uploads (as the attachment_fu plugin may do with images), is its _vulnerability to denial-of-service attacks_. An attacker can synchronously start image file uploads from many computers which increases the server load and may eventually crash or stall the server.
The solution to this is best to _process media files asynchronously_: Save the media file and schedule a processing request in the database. A second process will handle the processing of the file in the background.
--
cgit v1.2.3
From 0debba8899c64f80526ad08c9f535a40c808ece6 Mon Sep 17 00:00:00 2001
From: Nick Borromeo
Date: Sun, 13 Apr 2014 12:01:45 -0700
Subject: Disable assest cache store in docs [ci skip]
---
guides/source/asset_pipeline.md | 8 ++++++++
1 file changed, 8 insertions(+)
(limited to 'guides')
diff --git a/guides/source/asset_pipeline.md b/guides/source/asset_pipeline.md
index d688bb7b4e..d3dc790500 100644
--- a/guides/source/asset_pipeline.md
+++ b/guides/source/asset_pipeline.md
@@ -1041,6 +1041,14 @@ cache store.
config.assets.cache_store = :memory_store, { size: 32.megabytes }
```
+To disable the assets cache store:
+
+```ruby
+config.assets.configure do |env|
+ env.cache = ActiveSupport::Cache.lookup_store(:null_store)
+end
+```
+
Adding Assets to Your Gems
--------------------------
--
cgit v1.2.3
From 0e9fab5ff5c43d6f1c6b0eb8d0b1f988b499ebef Mon Sep 17 00:00:00 2001
From: Christopher Owen
Date: Mon, 14 Apr 2014 12:06:59 +1000
Subject: - Fix lingering reference to `:text` instead of the newer `:plain` -
Section references `form_tag` instead of the `form_for` used in the example
---
guides/source/getting_started.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'guides')
diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md
index bafb75c668..1ae7397696 100644
--- a/guides/source/getting_started.md
+++ b/guides/source/getting_started.md
@@ -612,7 +612,7 @@ def create
end
```
-The `render` method here is taking a very simple hash with a key of `text` and
+The `render` method here is taking a very simple hash with a key of `plain` and
value of `params[:article].inspect`. The `params` method is the object which
represents the parameters (or fields) coming in from the form. The `params`
method returns an `ActiveSupport::HashWithIndifferentAccess` object, which
@@ -1136,7 +1136,7 @@ The `method: :patch` option tells Rails that we want this form to be submitted
via the `PATCH` HTTP method which is the HTTP method you're expected to use to
**update** resources according to the REST protocol.
-The first parameter of the `form_tag` can be an object, say, `@article` which would
+The first parameter of `form_for` can be an object, say, `@article` which would
cause the helper to fill in the form with the fields of the object. Passing in a
symbol (`:article`) with the same name as the instance variable (`@article`) also
automagically leads to the same behavior. This is what is happening here. More details
--
cgit v1.2.3
From 1497529d05c8c5e66d9bad9b990b042442266136 Mon Sep 17 00:00:00 2001
From: ZENATI YASSINE
Date: Mon, 14 Apr 2014 15:55:11 +0200
Subject: [ci skip] Added link to ruby-lang.org installation.
---
guides/source/getting_started.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'guides')
diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md
index 1ae7397696..36bbd1187c 100644
--- a/guides/source/getting_started.md
+++ b/guides/source/getting_started.md
@@ -99,7 +99,7 @@ ruby 2.0.0p353
```
If you don't have Ruby installed have a look at
-[ruby-lang.org](https://www.ruby-lang.org/en/downloads/) for possible ways to
+[ruby-lang.org](https://www.ruby-lang.org/en/installation/) for possible ways to
install Ruby on your platform.
Many popular UNIX-like OSes ship with an acceptable version of SQLite3. Windows
--
cgit v1.2.3