Questions tagged [irb]

Interactive Ruby (IRB) is a shell for programming in Ruby. The program can be launched from a command prompt and allows the execution of Ruby commands line by line.

Interactive Ruby Shell (IRB) is a shell for programming in Ruby. The program can be launched from a command prompt and allows the execution of Ruby commands line by line. It features command history, line editing capabilities, and job control, and is able to communicate directly as a shell script over the Internet and interact with a live server. It was developed by Keiju Ishitsuka.

772 questions
35
votes
2 answers

Reload the rails console

Regarding the use of Rails console, when I make some change on a model, do I need to reload the rails console every time to make that change reflects? For example, I have my original code as follows: class Article < ActiveRecord::Base validates…
Sarun Sermsuwan
  • 3,608
  • 5
  • 34
  • 46
35
votes
3 answers

Why isn't current directory on my Ruby path?

Is there any reason why my present working directory is not on my Ruby path? Consider: ~:499$ irb ruby-1.9.2-p136 :002 > puts…
JnBrymn
  • 24,245
  • 28
  • 105
  • 147
34
votes
3 answers

How to load environment variables in the Rails console?

I think this is a little, easy question! I'm using .env file to keep all my environment variables, and i'm using foreman. Unfortunately, these environment variables are not being loaded when running rails console rails c so, i'm now loading them…
M.ElSaka
  • 1,264
  • 13
  • 20
33
votes
6 answers

Backspace and arrow keys aren't working in IRB(Git Bash console) on windows machine

I just installed ruby 1.9.2 on windows machine and Backspace or any other arrow keys don't work. This happens only when I open IRB on Git Bash console. But it works fine on Windows console. Any help on that? Note: IRB was working fine on both…
Vineeth Pradhan
  • 8,201
  • 7
  • 33
  • 34
33
votes
9 answers

What alternatives to IRB are there?

In the python world, there are a number of alternative python interpreters that add cool additional features. One particularly useful example is bpython, which adds dynamic syntax highlighting, automatically pulls documentation, and displays live…
Derek Thurn
  • 14,953
  • 9
  • 42
  • 64
30
votes
9 answers

How to run IRB.start in context of current class

I've been just going through PragProg Continuous Testing With Ruby, where they talk about invoking IRB in context of current class to inspect the code manually. However, they quote that if you invoke IRB.start in a class, self is predefined, and…
Jakub Arnold
  • 85,596
  • 89
  • 230
  • 327
30
votes
7 answers

Neither ruby and nor irb can load .rb file in current directory

I'm having a really noob problem with importing files in Ruby. I'm making a Ruby app in Windows XP. All the class files for the app are in "C:/Documents/Prgm/Surveyor_Ruby/lib". But when I require a file in another file, neither ruby nor irb can…
Bad Request
  • 3,990
  • 5
  • 33
  • 37
29
votes
2 answers

rails console - display active record results in a table

Is there a way to display Active Record results in table format in the script/console environment?
Power Point
  • 291
  • 1
  • 3
  • 3
28
votes
5 answers

How do I Quit IRB from the command line? (Using terminal on mac)

Basically, I'm typing along just fine in terminal, using IRB to run ruby commands: 2.0.0-p0 :014 > bank_account.withdraw(2222) => -1222 But sometimes I accidentally miss out a quotation mark. 2.0.0-p0 :020 >…
Starkers
  • 10,273
  • 21
  • 95
  • 158
26
votes
2 answers

Rails 3 - How can you get access to Devise's current_user in the IRB console?

I'm doing some design/debugging in IRB and need to login a user and then be able to use current_user in my efforts. From Brian Deterling's answer to another question, I have been able to successfully login and access a page response with this…
Don Leatham
  • 2,694
  • 4
  • 29
  • 41
25
votes
2 answers

Strange behavior with '_' (underscore) in Ruby

Just curious about it. If you open the IRB and type _, you'll get nil as response: irb(main):001:0> _ => nil And you can modify its value: irb(main):002:0> _ = 'some value' irb(main):003:0> _ => "some value" But if you create a new variable with…
Lucas Costa
  • 1,109
  • 9
  • 16
25
votes
1 answer

IRB history not working with Ruby 2.3.0

I have Ruby 2.3.0p0 installed via rbenv, on OS X 10.11.4. Within an IRB session, history works fine. However, I cannot access IRB history across sessions. I tried my system Ruby, 2.0.0p648, and history across IRB sessions works fine. I tried…
Evan Pon
  • 1,496
  • 1
  • 13
  • 22
25
votes
4 answers

How do I introspect things in Ruby?

For instance, in Python, I can do things like this if I want to get all attributes on an object: >>> import sys >>> dir(sys) ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__', '__stderr__', '__stdin__', '__stdout__',…
Jason Baker
  • 192,085
  • 135
  • 376
  • 510
23
votes
3 answers

Get all local variables or available methods from irb?

When I go into irb and type in a command that does not exist I get an error stating "undefined local variable or method 'my_method' for main:Object (NameError)" Is there a way to just get a list of what local variables or methods ARE available?…
George Mauer
  • 117,483
  • 131
  • 382
  • 612
21
votes
2 answers

Is there something like bpython for Ruby?

IRb is pretty plain compared to bpython, even when using wirble. Is there any ruby equivalent of bpython?
maček
  • 76,434
  • 37
  • 167
  • 198
1
2
3
51 52