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

How can I clear the rails console history

When I run rails c and press the up key when irb starts up, I can see the last commands I entered when my app dropped to irb after encountering a debugger command for the ruby-debug gem. I would not only like to clear these commands out, but I would…
Aaron
  • 13,349
  • 11
  • 66
  • 105
14
votes
1 answer

Regular expression "empty range in char class error"

I got a regex in my code, which is to match pattern of url and threw error: /^(http|https):\/\/([\w-]+\.)+[\w-]+([\w- .\/?%&=]*)?$/ The error was "empty range in char class error". I found the cause of that is in ([\w- .\/?%&=]*)? part. Ruby seems…
Steve
  • 141
  • 1
  • 1
  • 4
14
votes
3 answers

How to run Ruby programs in MAC OS Terminal

Possible Duplicate: How to run ruby files? I am starting to learn Ruby and having a hard time running the Ruby classes in the Terminal. I created a class in the Sublime Text editor, just "hello world". I can compile using ruby hello.rb, but how…
Ducati007
  • 265
  • 1
  • 5
  • 14
13
votes
4 answers

How do you save IRB inputs to a .rb file?

Might sound like a newbie question (and it is since I am new to Ruby and IRB) but is there a way to save the commands you did in IRB to file? I am playing with WATIR and would love to save all my inputs to file instead of copying and pasting…
Enrique
  • 655
  • 1
  • 7
  • 16
12
votes
1 answer

why does irb freak out sometimes when I paste in a script?

def load_lib path = File.join(File.dirname(__FILE__), 'lib') failures = [] Dir.glob("#{path}/**/*.rb").each { |file| puts "loading: #{file} ... " } end There's the script. When I put each line in individually, the load_lib…
jcollum
  • 43,623
  • 55
  • 191
  • 321
12
votes
3 answers

How to attach the Rubymine IDE debugger to a shell process?

I want to use Rubymine's IDE debugger to debug a ruby process running in the command shell, as it is spawned, e.g. by "rails console". I've gotten great mileage out of the debugger when running the web server (from within Rubymine) or test suites…
Wolfram Arnold
  • 7,159
  • 5
  • 44
  • 64
12
votes
2 answers

Why does the =~ operator only sometimes have side effects?

I've noticed a side effect in Ruby/Oniguruma that is only present in 1 out of 4 seemingly equivalent statements. Why is the variable day defined in 009, but not in 003, 005 or 007? irb(main):001:0> r = /(?\d\d):(?\d\d)/ =>…
Staffan Nöteberg
  • 4,095
  • 1
  • 19
  • 17
12
votes
3 answers

How can I pass to IRB if I don't specify ?

Since: irb --help Usage: irb.rb [options] [programfile] [arguments] I know I can pass arguments to ARGV if I include a programfile eg: irb test.rb A B C where test.irb is simply "p ARGV" produces: ["a", "b", "c"] Making programfile be con in…
DMisener
  • 891
  • 1
  • 8
  • 15
12
votes
2 answers

How to disable the logger in script/console

In my .irbrc file I require 'logger' to allow me to see the SQL executed when querying ActiveRecords all while in the script/console. My question is, how do I temporarily turn off the logger so it doesn't display the SQL just for a few ActiveRecord…
Coderama
  • 11,050
  • 12
  • 44
  • 58
12
votes
2 answers

Rails console - use image_tag method

How can I execute a image_tag method in a Rails console Run the console $ rails c Load helpers include ActionView::Helpers Execute the command image_tag('test.png') I got a strange error. Please help!
xpepermint
  • 35,055
  • 30
  • 109
  • 163
12
votes
1 answer

rails console pry/irb "stuck" after displaying long value/string

I am developing with rails on a mac using the rails console via pry/irb. When I display a long result in the console ie. Model.all or .really_long_string, I cant seem to get past the string or value that is displayed and the console displays…
koa
  • 515
  • 6
  • 17
12
votes
4 answers

Can't enter Umlauts in Ruby 1.9.3 IRB

I am experiencing very strange behavior in Ruby 1.9.3's IRB with Mac OS 10.7.3 When I try to enter an Umlaut, it's escaped in the prompt and looks like this (I entered "ü" on the keyboard) irb(main):001:0> "\U+FFC3\U+FFBC" What's super strange is…
Jan
  • 950
  • 7
  • 14
11
votes
4 answers

how can I change the default syntax coloring in ruby 3.0's IRB

I'm very happy to be using the most recent ruby 3.0; as well as having access to the updated command-line interpreter which does syntax highlighting and coloring. However, the colors are a bit hard to see for me. How can I change them? The command…
Simon DeDeo
  • 111
  • 1
  • 3
11
votes
5 answers

How do I start IRB console from a rake task?

I'm trying to write a rake task that will set up an environment mirroring my project. task :environment do require 'rubygems' require 'sequel' # require 'my_projects_special_files' end task :foo => [:environment] do require 'irb' …
Michael Lang
  • 1,028
  • 12
  • 21
11
votes
1 answer

Easy way to suppress SQL output in Rails console?

I frequently need to go on the Rails console with rails c. Then I run some statement which loops through records of a model. I need to output information, but all the SQL code gets littered throughout as well. Like: Students.all.each {|s| puts…
at.
  • 50,922
  • 104
  • 292
  • 461