aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-06-20 12:42:38 +0200
committerYves Senn <yves.senn@gmail.com>2014-06-20 12:42:38 +0200
commit75e4d0931e41314667fcdbaf29caf87efdeb1d65 (patch)
tree0627c9f6f70aa63b37012ba4962791d60802ce72 /guides
parentedc0f271978585635153068c708d62f5243dafe0 (diff)
parent4251af5235616472b46e9b4bdcac6447581bc1fd (diff)
downloadrails-75e4d0931e41314667fcdbaf29caf87efdeb1d65.tar.gz
rails-75e4d0931e41314667fcdbaf29caf87efdeb1d65.tar.bz2
rails-75e4d0931e41314667fcdbaf29caf87efdeb1d65.zip
Merge pull request #15809 from maurogeorge/guides-console-app
Add to guides app and helper objects on command line
Diffstat (limited to 'guides')
-rw-r--r--guides/source/command_line.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/guides/source/command_line.md b/guides/source/command_line.md
index 7e60f929a1..e283bcd0ef 100644
--- a/guides/source/command_line.md
+++ b/guides/source/command_line.md
@@ -294,6 +294,31 @@ Any modifications you make will be rolled back on exit
irb(main):001:0>
```
+#### The app and helper objects
+
+Inside the `rails console` you have access to the `app` and `helper` instances.
+
+With the `app` method you can access url and path helpers, as well as do requests.
+
+```bash
+>> app.root_path
+=> "/"
+
+>> app.get _
+Started GET "/" for 127.0.0.1 at 2014-06-19 10:41:57 -0300
+...
+```
+
+With the `helper` method it is possible to access Rails and your application's helpers.
+
+```bash
+>> helper.time_ago_in_words 30.days.ago
+=> "about 1 month"
+
+>> helper.my_custom_helper
+=> "my custom helper"
+```
+
### `rails dbconsole`
`rails dbconsole` figures out which database you're using and drops you into whichever command line interface you would use with it (and figures out the command line parameters to give to it, too!). It supports MySQL, PostgreSQL, SQLite and SQLite3.