Last active
June 20, 2019 23:43
-
-
Save danilocandido/8759d290a7ba467284ec387be20f7b98 to your computer and use it in GitHub Desktop.
Tips for rails console
This file contains hidden or 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
# add a .pryrc file or .irbrc | |
class Object | |
def me | |
User.find_by(email: '[email protected]') | |
end | |
def slmn | |
SomeLongModelName | |
end | |
def an_array | |
(1..5).to_a | |
end | |
def a_hash | |
{a: 'b', c: 'd'} | |
end | |
end | |
# prevent console from spending time rendering output we don’t care about | |
users = User.all; nil | |
# sandbox | |
rails console --sandbox | |
# The variable _ refers to the result of the last command run | |
my_variable = _ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment