Skip to content

Instantly share code, notes, and snippets.

@danilocandido
Last active June 20, 2019 23:43
Show Gist options
  • Save danilocandido/8759d290a7ba467284ec387be20f7b98 to your computer and use it in GitHub Desktop.
Save danilocandido/8759d290a7ba467284ec387be20f7b98 to your computer and use it in GitHub Desktop.
Tips for rails console
# 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