Skip to content

Instantly share code, notes, and snippets.

@stevenyap
Last active December 25, 2015 20:59
Show Gist options
  • Save stevenyap/7039084 to your computer and use it in GitHub Desktop.
Save stevenyap/7039084 to your computer and use it in GitHub Desktop.
List of rails command lines

Starts the rails server

rails s

View a running list of the development log

tail -f log/development.log

Starts the rails console

rails c

rails dbconsole # starts the DB console

Useful rails console commands

Last Value: _

_ represents the last value returned from rails console and you can assign it to a variable for further usage:

var = _

ls to examine a variable

  • The command ls returns the list of methods from the variable
  • Note that this is availabe only from the gem pry
ls var

List methods of a variable

  • Returns all methods of var less the methods of 1 (object methods)
  • 1 is an object and it represents the common methods of all objects
  • So removing it will enable us to examine the additional methods of
<var>.methods.sort - 1.methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment