Last active
December 19, 2015 22:19
-
-
Save anaerobeth/6026603 to your computer and use it in GitHub Desktop.
Notes on Railscasts #48 Console Tricks (revised)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On the Terminal: | |
rails console #open a terminal window | |
rails c --sandbox #console session that is wrapped in a transaction and can be rolled back | |
rails c --production #start the app in the production environment | |
Console methods: | |
> app | |
> app.products_path # call URL helpers to see where a path routes to | |
> app.get app.products_path # make requests to the app and pass in a path | |
> app.cookies # see which cookies are set | |
> app.response.headers # see the headers of the last response | |
> app.response.body # see the body of the last response | |
> app.assigns(:products).size # inspect the instance variables in the last request | |
> helper | |
> helper.number_to_currency(12.34) # gives access to the view context and we can execute helper methods | |
> helper.controller = controller # returns a new ApplicationController instance | |
Gems That Work With irb: | |
Hirb # displays ActiveRecord data in a table. | |
Awesome Print # shows models’ attributes formatted and with colour | |
Clipboard gem # allows interaction with the system’s clipboard | |
MethodFinder # context-based search for methods, for example: "abc".find_method("ABC") | |
FancyIrb # displays results inline | |
Wirb # displays outputs in color | |
Special note: | |
Pry #replacement for irb with many extra features |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment