What alternatives to IRB are there?

Use Pry: https://github.com/pry/pry Let’s you: start sessions at runtime view method source code view method documentation (not using RI so you dont have to pre-generate it) pop in and out of different contexts syntax highlighting gist integration view and replay history open editors to edit method using edit-method obj.my_method syntax A tonne more great and … Read more

Reload the rails console

Yes, you need to call reload! as this will clear the loaded constants that have been loaded and will load them as they’re referenced in the console. If you have old objects from before the reload! you will need to call reload on these individual objects or find new objects and work with them if … Read more

Why isn’t current directory on my Ruby path? [duplicate]

In Ruby 1.9.2 the Powers that Be introduced an explicit change so that the working directory is no longer in the Ruby path. I thought it was the Apocalypse and a terrible thing, until I learned about require_relative. My apps tend to look like this: require ‘some_gem’ require ‘another_gem’ require_relative ‘lib/init’ And then lib/init.rb can … Read more

How to suppress the output of return value in IRB/Rails Console?

If you just want to suppress long output once in a while, use ;0, like: a = [*1..10000];0 # => 0 If you want to suppress it generally, use the ~/.irbrc file. The IRB.conf[:INSPECT_MODE] and IRB.conf[:PROMPT][your_prompt][:RETURN] control what is returned. You can figure out what your_prompt is by checking IRB.conf[:PROMPT_MODE] Example: IRB.conf[:PROMPT][:DEFAULT][:RETURN] = “” # … Read more

How do you list the currently available objects in the current scope in ruby?

I’m not entirely sure of what you mean by the ‘current objects’. You can iterate over ObjectSpace, as has been mentioned already. But here are a few other methods. local_variables instance_variables global_variables class_variables constants There’s one gotcha. They must be called at the right scopes. So right in IRB, or in an object instance or … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)