From 4dd764207cce57ae4f592b383620b2f49fe2c727 Mon Sep 17 00:00:00 2001 From: Karel Minarik Date: Sat, 17 Jan 2009 19:12:13 +0100 Subject: Clarifications and additions to the introduction part of Internationalization (I18n) guide --- .../guides/html/debugging_rails_applications.html | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'railties/doc/guides/html/debugging_rails_applications.html') diff --git a/railties/doc/guides/html/debugging_rails_applications.html b/railties/doc/guides/html/debugging_rails_applications.html index 07557b9e99..51db11eb4e 100644 --- a/railties/doc/guides/html/debugging_rails_applications.html +++ b/railties/doc/guides/html/debugging_rails_applications.html @@ -160,7 +160,7 @@ Analyze the stack trace

1.1. debug

The debug helper will return a <pre>-tag that renders the object using the YAML format. This will generate human-readable data from any object. For example, if you have this code in a view:

-
@@ -188,7 +188,7 @@ Title: Rails debugging guide

1.2. to_yaml

Displaying an instance variable, or any other object or method, in yaml format can be achieved this way:

-
@@ -216,7 +216,7 @@ Title: Rails debugging guide

1.3. inspect

Another useful method for displaying object values is inspect, especially when working with arrays or hashes. This will print the object value as a string. For example:

-
@@ -236,14 +236,14 @@ Title: Rails debugging guide

Rails has built-in support to debug RJS, to active it, set ActionView::Base.debug_rjs to true, this will specify whether RJS responses should be wrapped in a try/catch block that alert()s the caught exception (and then re-raises it).

To enable it, add the following in the Rails::Initializer do |config| block inside environment.rb:

-
config.action_view[:debug_rjs] = true

Or, at any time, setting ActionView::Base.debug_rjs to true:

-
@@ -264,7 +264,7 @@ http://www.gnu.org/software/src-highlite -->

Rails makes use of Ruby’s standard logger to write log information. You can also substitute another logger such as Log4R if you wish.

You can specify an alternative logger in your environment.rb or any environment file:

-
@@ -272,7 +272,7 @@ http://www.gnu.org/software/src-highlite --> ActiveRecord::Base.logger = Log4r::Logger.new("Application Log")

Or in the Initializer section, add any of the following

-
@@ -290,7 +290,7 @@ config.logger =

When something is logged it’s printed into the corresponding log if the log level of the message is equal or higher than the configured log level. If you want to know the current log level you can call the ActiveRecord::Base.logger.level method.

The available log levels are: :debug, :info, :warn, :error, and :fatal, corresponding to the log level numbers from 0 up to 4 respectively. To change the default log level, use

-
@@ -308,7 +308,7 @@ ActiveRecord::Base2.3. Sending Messages

To write in the current log use the logger.(debug|info|warn|error|fatal) method from within a controller, model or mailer:

-
@@ -317,7 +317,7 @@ logger.info "Pr logger.fatal "Terminating application, raised unrecoverable error!!!"

Here’s an example of a method instrumented with extra logging:

-
@@ -368,7 +368,7 @@ Completed in 0.01224 (81 reqs/sec) | DB: 0.00044 (3%) | 302 Found [http://localh

3.1. Setup

The debugger used by Rails, ruby-debug, comes as a gem. To install it, just run:

-
@@ -377,7 +377,7 @@ http://www.gnu.org/software/src-highlite -->

Rails has had built-in support for ruby-debug since Rails 2.0. Inside any Rails application you can invoke the debugger by calling the debugger method.

Here’s an example:

-
@@ -394,7 +394,7 @@ http://www.gnu.org/software/src-highlite -->

Make sure you have started your web server with the option --debugger:

-
@@ -620,7 +620,7 @@ true

The difference between next and step is that step stops at the next line of code executed, doing just a single step, while next moves to the next line without descending inside methods.

For example, consider this block of code with an included debugger statement:

-
@@ -833,7 +833,7 @@ set listsize 25

Then setup you application for profiling. Then add the following at the bottom of config/environment.rb:

-
-- cgit v1.2.3