irb

can't start script/console with Ruby 1.9 and Rails 2.3.4

Hi, I'm trying to start the console (irb) in Ruby 1.9 with Rails 2.3.4. I have two versions installed of Ruby (1.9 & 1.8.6) and I run the Ruby 1.9 by calling: rake19, ruby19, gem19...etc And they work fine in all situations except this! it seems that its trying to load Ruby 1.8 instead! Do you know how I can change that? Macintosh-10:...

History not saving

Why is my irb history no longer saving? ...

How do I compile Readline support into Ruby

My version of ruby was compiled with editline (on os x) and I miss the features of readline in irb. How do I recompile ruby with readline support? ...

Ruby Irb reacts strangely to control keys

Hi. I'm (extremely) new to Ruby, having started today. I just moved from my system's Ruby 1.8 installation to Ruby 1.9, compiled from source. In doing so, irb has taken a turn for the worse. It reacts in a most unfriendly way to the non-alphanumeric control keys: UP key prints: ^[[A DOWN key prints: ^[[B DELETE key prints: ^[[3~ ...

how to get the current working directory's absolute path from irb

I'm running Ruby on Windows though I don't know if that should make a difference. All I want to do is get the current working directory's absolute path. Is this possible from irb? Apparently from a script it's possible using File.expand_path(FILE) But from irb I tried the following and got a "Permission denied" error: File.new(Dir.n...

irb history not working

in ~/.irbrc i have these lines: require 'irb/ext/save-history' #History configuration IRB.conf[:SAVE_HISTORY] = 100 IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" and yet when i run irb and hit the up arrow nothing happens. also the irb history file specified is not getting created and nothing is logged to it. ...

How can a Ruby script detect that it is running in irb?

I have a Ruby script that defines a class. I would like the script to execute the statement BoolParser.generate :file_base=>'bool_parser' only when the script is invoked as an executable, not when it is require'd from irb (or passed on the command line via -r). What can I wrap around the statement above to prevent it from executing ...

Keybinding move word in JRuby irb on OSX

Similar to this question, except in JRuby (it works in MRI Ruby). Alt-left prints a "b" in my console. Very annoying! To clarify, I've setup my terminal as described in this article, mapping option-left to escape-b. ...

Ruby IRB output is messed up in the console on Windows 7

I am getting very strange outputs from my IRB console. Here it is: irb(main):001:0> File.dirname(__FILE__) => ←[0;31m"←[0;0m←[0;36m.←[0;0m←[0;31m"←[0;0m Seems like an encoding issue, right? I am not sure why this is happening. Any ideas how to fix it? ...

Rails check if IRB console or webpage

I my model I would like to check if the app is running inside IRB consol or as a website? class MyModel < ActiveRecord::Base def xmethod if !isIRBconsol self.user_id = UserSession.find.user.id end end end ...

ActiveRecord Claims No Adaptor Specified

When I try to run the following, I get an error back from ActiveRecord stating that the connector hasn't been found. require 'activerecord' ActiveRecord::Base.establish_connection( :adaptor => "sqlite3", :database => "db.sqlite3" ) Error Message: >> ActiveRecord::Base.establish_connection("adaptor" => "sqlite3-ruby") ActiveR...

Does a Rails 3.0.0.beta app only see bundled gems in the console?

I have a library that I'm trying to get working with rails 3 (specifically feedzirra) which I can require ok in irb but it breaks the console in my app with the following error: http://pastie.org/855976 ...

What's the difference between the ruby irb prompt modes?

I can change the irb prompt mode with irb --prompt prompt-mode I can see what null and simple does, but I can't tell the difference between null and xmp and the difference between default/classic/inf-ruby. Can someone explain to me what these other modes do? It seems pointless to have multiple modes doing the same thing. ...

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__', '_clear_type_cache', '_current_frames', '_getframe', 'api_version', 'argv', 'builtin_module_name...

active record helpers defined in ~/.irbrc

I'm really tired of typing my_ar_object.errors.full_messages in my console when i'm testing things... So, I want to define this: module ActiveRecord class Base def err errors.full_messages end end end in my ~/.irbrc so that it is exclusive to script/console. I don't want to define it in some rails initializer since...

Ruby: counters, counting and incrementing

Hi, If you have seen my previous questions, you'd already know I am a big nuby when it comes to Ruby. So, I discovered this website which is intended for C programming, but I thought whatever one can do in C, must be possible in Ruby (and more readable too). The challenge is to print out a bunch of numbers. I discovered this nifty met...

IRb: how to start an interactive ruby session with pre-loaded classes

Hi, As I am going through my journey by adopting the Ruby language, I spend a lot of time inside IRb. It's just fantastic! But, as I am not very aware of it's capabilities, and still a nuby with Ruby, I would like to know the following: How can I 'flush' the session, without restarting IRb (or is this not possible). How can I configur...

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' IRB.start end Leads to irb complaining that "foo" doesn't exist (the name of the task) 10:28...

Ruby IRB - Requires and Scope

Trying to understand this problem I'm running into. I create file welcome.rb. The contents of this file: welcome_message = "hi there" I then launch an irb session. And type require 'welcome'. That works fine. Then I type: puts welcome_message I get the error message undefined local variable or method `welcome_message' for main:Obj...

~/.irbrc not executed when starting irb or script/console

Here's what I've tried: 1. gem install awesome_print 2. echo "require 'ap'" >> ~/.irbrc 3. chmod u+x ~/.irbrc 4. script/console 5. ap { :test => 'value' } Result: NameError: undefined local variable or method `ap' for # ...