# Is IRB the ruby console?

**URL:** <https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937>\
**Category:** Rails\
**Created:** [June 9, 2006, 6:45pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937 "2006-06-09T18:45:05Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 6:45pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/1 "2006-06-09T18:45:05Z")

</div>

I’m running script/console but keep getting the message that irb.bat is  
not  
recognized as an internal or external command, operable program or  
batch  
file.

If it means anything I am running instant rails. I can invoke irb  
straight  
forward.

TIA  
Stuart

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 6:55pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/2 "2006-06-09T18:55:03Z")

</div>

On 6/9/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

IRB is the Interactive RuBy interpreter. Basically a read-eval loop  
for Ruby with some niceties.

Win32 installations of Ruby tend to have it invoked by the batch  
C:\ruby\bin\irb.bat. You probably have it, if you can invoke IRB by  
simply “irb” from the command line. Not sure how instant Rails handles  
it. You might want to make sure you indeed have it, and also that  
C:\ruby\bin is in PATH. My guess would be that they are, and instant  
Rails is looking for irb.bat in some specific place that it’s not.

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 7:14pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/3 "2006-06-09T19:14:17Z")

</div>

On 6/9/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks for the response, I was able to pull up irb via irb.bat. My problem  
> though is I’m not sure it’s what is needed. I’m working on a tutorial and  
> have these instructions:
> 
> "At this point, lets test out our user model object. We can do this in the  
> ruby console. Go to your console window run the following:
> 
> rubyuser@linux:~/workspace/SecuredApp\> ruby script/console  
> Loading development environment.

SecuredApp is the Rails application directory (codenamed RAILS\_ROOT).  
It’s the directory created when you run

rails SecuredApp

/script is a standard subdirectory automatically created within any  
Rails application directory. And /console is one of the (useful)  
scripts automatically generated for you.

Clear now?

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 7:17pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/4 "2006-06-09T19:17:55Z")

</div>

irb is interactive ruby but it knows nothing about your application,  
etc.

console is a rails application and differs from irb in that it does know  
something about rails and can use your application/models, etc.

from the rails\_root directory, like you would invoke server, you would  
invoke console…

ruby script/server  
ruby script/console

Craig

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 7:21pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/5 "2006-06-09T19:21:07Z")

</div>

Clearer :), but still lacking the clarity to complete the task .  
Do I enter the text as code into the script / console file and then  
somehow  
run it ?

Stuart

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 7:29pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/6 "2006-06-09T19:29:10Z")

</div>

Dark A. wrote:

> Clearer :), but still lacking the clarity to complete the task .  
> Do I enter the text as code into the script / console file and then  
> somehow  
> run it ?
> 
> Stuart

No. When you run script/console, Rails loads your development code (ie,  
the models that you’ve specified in the app/models folder), and you are  
presented with an interactive prompt. At that point you can execute  
whatever Ruby code you want to inspect or change your models. So  
following the above tutorial, you would type the following at the  
prompt:

standon = User.new(:username =\> “standon”)

which would create a new User object with the username set to “standon”

It saves you from having to write this code in your controller and then  
output it in your view.

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 7:30pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/7 "2006-06-09T19:30:52Z")

</div>

On 6/9/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Clear now?
> > 
> > > > > standon.password\_salt
> > > 
> > > straight
> > > 
> > > > > 
> > > > 
> > > > C:\ruby\bin is in PATH. My guess would be that they are, and instant
> > 
> > -Alder  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

Yes. script/console is very much like IRB. You type ruby expressions  
after the prompt, and run (well more accurately “evaluate”) them by  
pressing Enter.

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 7:01pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/8 "2006-06-09T19:01:16Z")

</div>

Thanks for the response, I was able to pull up irb via irb.bat. My  
problem  
though is I’m not sure it’s what is needed. I’m working on a tutorial  
and  
have these instructions:

"At this point, lets test out our user model object. We can do this in  
the  
ruby console. Go to your console window run the following:

rubyuser@linux:~/workspace/SecuredApp\> ruby script/console  
_Loading development environment._

Now create a new user:

> > standon = User.new(:username =\> “standon”)  
> > _=\> #nil, “username”=\>“standon”, “password\_hash”=\>nil}\>_

Set the password:

> > standon.password = “secret”  
> > _=\> “secret”_

Check the password\_hash and password\_salt properties. Notice how they  
were  
set by the password setter method we wrote:

> > standon.password\_hash  
> > _=\> "d357cb1a9d6bff0393b4ad8f338e3f29b24a16e3â?³_
> 
> > standon.password\_salt  
> > _=\> “+RH7rfvB” …"_

\*\*

_It goes on but I’'m totally confused as to where any of this is to be  
performed._

Stuart  
\*\*

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 7:37pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/9 "2006-06-09T19:37:28Z")

</div>

It must be missing then from my configuration. I either get nothing or  
a  
load error.

Stuart

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 7:43pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/10 "2006-06-09T19:43:47Z")

</div>

Here is what I get just typing ruby script/console:

C:\InstantRails\ruby\bin\>ruby script/console  
ruby: No such file or directory – script/console (LoadError)

I might have some environment issues , but I ran this from the ruby /  
bin  
directory.

Stuart

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 7:44pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/11 "2006-06-09T19:44:08Z")

</div>

On 6/9/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It must be missing then from my configuration. I either get nothing or a  
> load error.

I’m not positive, but I believe with Instant Rails you need to launch  
the console window from within the Instant Rails control panel  
thingie… I would check the documentation on it to be sure.

-Curtis

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 7:47pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/12 "2006-06-09T19:47:19Z")

</div>

On 6/9/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > On 6/9/06, Dark A. \< removed\_email\_address@domain.invalid\> wrote:
> > > 
> > > > > > > > standon.password\_hash  
> > > > > > > > performed.  
> > > > > > > > recognized as an internal or external command, operable  
> > > > > > > > Stuart
> > > > > > > 
> > > > > > > it. You might want to make sure you indeed have it, and also  
> > > > > > > removed\_email\_address@domain.invalid
> > > 
> > > Yes. script/console is very much like IRB. You type ruby expressions
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

/ is not standard Win32 notation. Try

ruby script\console

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 7:50pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/13 "2006-06-09T19:50:41Z")

</div>

On 6/9/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I might have some environment issues , but I ran this from the ruby / bin  
> directory.

It needs to be run from your root application directory. For  
instance, I use mine in documents and settings; with each application  
under a “rails” directory. So I would traverse to:

c:\documents and settings\curtis\rails\arailsapp\>ruby script/console

And I would get a console linking into the code for the arailsapp  
application. I still think Instant Rails may do it a little  
differently though. I recall a few things along those lines that led  
me away from it to just install everything from scratch…

-Curtis

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 7:50pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/14 "2006-06-09T19:50:31Z")

</div>

Dark A. wrote:

> Here is what I get just typing ruby script/console:
> 
> C:\InstantRails\ruby\bin\>ruby script/console  
> ruby: No such file or directory – script/console (LoadError)
> 
> I might have some environment issues , but I ran this from the ruby /  
> bin directory.
> 
> Stuart

To the best of my knowledge, you should run that command in the APP  
directory. Since you are using InstantRails, it should be something  
like (for the application “cookbook”)  
c:\InstantRails\rails\_apps\cookbook\>ruby script/console  
or  
c:\InstantRails\rails\_apps\cookbook\>ruby script\console

Hope this helps.  
Mohit.

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 7:53pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/15 "2006-06-09T19:53:54Z")

</div>

Just as I was about to add ruby/bin to the environment variables your  
email  
came through. Yes, I opened the console window from Instantrails and  
while  
it looked like a regular cmd window , the command script/console worked.  
My apologies, I’ve been doing most of the work in radrails and  
completely  
forgot about the console option.  
Thanks to all for the help and my apologies for being totally stupid  
about  
this.

Stuart

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 8:03pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/16 "2006-06-09T20:03:54Z")

</div>

On 6/9/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Just as I was about to add ruby/bin to the environment variables your email  
> came through. Yes, I opened the console window from Instantrails and while  
> it looked like a regular cmd window , the command script/console worked.  
> My apologies, I’ve been doing most of the work in radrails and completely  
> forgot about the console option.  
> Thanks to all for the help and my apologies for being totally stupid about  
> this.

Heehee… None of us (except maybe the core team) knew all of this  
stuff when they were born… No worries. 🙂

-Curtis

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 8:51pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/17 "2006-06-09T20:51:53Z")

</div>

Seems like one spends more time trying to figure out how to get the  
system  
working and then debugging bad code.

If it’s okay though I’ll use this thread since now that I have the  
console  
running it’s spitting out an error that I’m not clear on.

First the error:

> > standon = User.new(:user\_name =\> “standon”)  
> > NameError: uninitialized constant User  
> > from  
> > C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active\_support/dependencies.rb:100:in  
> > `const_missing' from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:in`  
> > const\_missing’  
> > from (irb):3
> 
> >

Yet here in the model it looks like user is defined:  
def self.login(username, password)

```
        user = User.find(:first, :conditions => ['user_name = ?' ,

```

user\_name])  
if user

```
            expected_password = encrypted_password(password,

```

user.password\_salt)  
if user.password\_hash != expected\_password

```
                user = nil

            end

        end
        user #this makes no sense to but

    end

```

Stuart

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 8:58pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/18 "2006-06-09T20:58:26Z")

</div>

On 6/9/06, Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active\_support/dependencies.rb:100:in  
> def self.login(username, password)
> 
> ```
> end
> 
> end
> user #this makes no sense to but
> 
> end
> 
> ```
> 
> Stuart

Stuart:

I would recommend gaining a good understanding of the basic concepts  
of Ruby and Rails first.

Asking about every error you get here would likely not be productive  
for you or the medium.

AWDWR and Ruby for Rails would be good introductory texts.

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 9, 2006, 9:04pm UTC](https://www.ruby-forum.com/t/is-irb-the-ruby-console/62937/19 "2006-06-09T21:04:52Z")

</div>

My apologies Alder, thank you !

Stuart
