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
8
votes
3 answers

Disabling irb autocomplete on Heroku

A follow up to Disable irb autocomplete I would like to disable IRB on Heroku, e.g. having an .irbrc with: IRB.conf[:USE_AUTOCOMPLETE] = false In the home directory of my heroku dyno/server How can I do it?
Dorian
  • 7,749
  • 4
  • 38
  • 57
8
votes
1 answer

Undoing auto-indentation

Wnen you use irb with auto indent mode, the end statements get indented one level extra def foo ... end instead of showing the ordinary indenting convention: def foo ... end because you cannot tell irb in advance that you are going to…
sawa
  • 165,429
  • 45
  • 277
  • 381
8
votes
1 answer

In Ruby, if you assign a function to a variable, why does it automatically run?

Using the code below: variable = puts "hello world".upcase Why does Ruby automatically puts Hello world in upcase, without the variable first being invoked? I understand that you are setting the function to the variable, and if that variable is…
developer098
  • 773
  • 2
  • 10
  • 18
8
votes
4 answers

accessing variables in loaded source while in irb

Say I have a file named test1.rb with the following code: my_array = [1, 2, 3, 4 5] Then I run irb and get an irb prompt and run "require 'test1'. At this point I am expecting to be able to access my_array. But if I try to do something like... puts…
iljkj
  • 779
  • 1
  • 9
  • 13
8
votes
1 answer

How to kill a scan operation in hbase shell without Ctrl-C

Sometimes when I run a scan '. I see a continuous flood of data being printed because the table is big. I want to kill the process that print the data. Is there a way to do it other than Ctrl-C? because Ctrl-C kills the shell process and…
ssgao
  • 5,151
  • 6
  • 36
  • 52
8
votes
1 answer

Can't find gems in irb: "NameError: uninitialized constant Gem from (irb)"

When I run a Rails app it finds all of my installed gems correctly. This is the first time I tried to call some gems from inside irb and it couldn't find them. blocke:~$ irb irb(main):001:0> require 'rubygems' => true irb(main):002:0> require…
Bryan Locke
  • 2,337
  • 5
  • 25
  • 30
8
votes
2 answers

RubyOnRails: How do I use helper methods in Rails Console?

Probably something wrong with my setup: irb(main):001:0> truncate("Once upon a time in a world far far away", :length => 17) NoMethodError: undefined method `truncate' for main:Object from (irb):1 from…
TopperH
  • 2,183
  • 18
  • 33
8
votes
2 answers

Digest::MD5 in Ruby 1.9.3

I'm running into something weird here. I have an "authenticator" that relies on ND5 to hash a certain string we match as password. The problem when I run my tests is this: NoMethodError: undefined method `md5' for…
codingbunny
  • 3,989
  • 6
  • 29
  • 54
8
votes
2 answers

suppressing IRB output?

Possible Duplicate: Rails console, how to stop output of return value? Consider this session in IRB: >> for a in 1..5 do ?> puts a >> end 1 2 3 4 5 => 1..5 >> How do I suppress the output => 1..5? This is important if I do this in a Rails…
highBandWidth
  • 16,751
  • 20
  • 84
  • 131
8
votes
3 answers

Unicode characters in Ruby 1.9.3 IRB with RVM

Update: I found almost exact similar question, yet it has slightly different prerequisites and thus doesn't help much. Given: MacOS Lion 10.7.3 rvm 1.14.2 ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0] Ruby was installed with the…
oldhomemovie
  • 14,621
  • 13
  • 64
  • 99
8
votes
4 answers

Why does Ruby tend to assign object IDs in descending order?

I've noticed that objects have their IDs assigned in a counterintuitive fashion. The earlier an object is created, the greater its object ID. I would have thought they would have been assigned in ascending order, rather than the other way…
Matty
  • 33,203
  • 13
  • 65
  • 93
7
votes
2 answers

Is there a way to get out of a "hung" state in IRB?

When using irb or rails console, I sometimes get stuck. For example, I forget a closing quote, so when I press enter, it's still waiting on that. Sometimes I can get out of this (by suppyling the closing quote, for example), but sometimes I can't.…
Nathan Long
  • 122,748
  • 97
  • 336
  • 451
7
votes
3 answers

Reading docs in irb

One thing I miss about ipython is it has a ? operator which diggs up the docs for a particular function. I know ruby has a similar command line tool but it is extremely inconvenient to call it while I am in irb. Does ruby/irb have anything similar?
xjq233p_1
  • 7,810
  • 11
  • 61
  • 107
7
votes
2 answers

NameError: uninitialized constant Object::User

I searched the other posts that had this issue and could not find one that fixed my particular issue. My irb is going crazy. I am trying to change user roles in my database but I can't even get to my users! irb(main):001:0> User.all NameError:…
Sako Kassabian
  • 145
  • 1
  • 7
7
votes
2 answers

Rails console tips, tricks and customizations

There's this great post on irb tricks, but what about further customizing Rails console behavior and output? Awesome print and Hirb are great. SQL logging is a must for me. In your ~/.irbrc paste: require 'logger' ActiveRecord::Base.logger =…
Mirko
  • 5,207
  • 2
  • 37
  • 33