Is IRB the ruby console?

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

On 6/9/06, Dark A. [email protected] wrote:


Rails mailing list
[email protected]
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.

On 6/9/06, Dark A. [email protected] 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?

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

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

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.

On 6/9/06, Dark A. [email protected] 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

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.

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
**

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

Stuart

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

On 6/9/06, Dark A. [email protected] 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

On 6/9/06, Dark A. [email protected] wrote:

On 6/9/06, Dark A. < [email protected]> 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
[email protected]

Yes. script/console is very much like IRB. You type ruby expressions


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

/ is not standard Win32 notation. Try

ruby script\console

On 6/9/06, Dark A. [email protected] 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

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.

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

On 6/9/06, Dark A. [email protected] 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. :slight_smile:

-Curtis

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

On 6/9/06, Dark A. [email protected] 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.

My apologies Alder, thank you !

Stuart