Forum: Ruby on Rails Is IRB the ruby console ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
620c12639078ea2dde8a3b50ccee4c05?d=identicon&s=25 Dark Ambient (Guest)
on 2006-06-09 18:45
(Received via mailing list)
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
B780ee0ee1480454a85df58536702f63?d=identicon&s=25 Alder Green (Guest)
on 2006-06-09 18:55
(Received via mailing list)
On 6/9/06, Dark Ambient <sambient@gmail.com> wrote:
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> 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.
620c12639078ea2dde8a3b50ccee4c05?d=identicon&s=25 Dark Ambient (Guest)
on 2006-06-09 19:01
(Received via mailing list)
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
**
B780ee0ee1480454a85df58536702f63?d=identicon&s=25 Alder Green (Guest)
on 2006-06-09 19:14
(Received via mailing list)
On 6/9/06, Dark Ambient <sambient@gmail.com> 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?
C1e5a9e9344b6d31b9df7303e6dc378a?d=identicon&s=25 Craig White (Guest)
on 2006-06-09 19:17
(Received via mailing list)
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
620c12639078ea2dde8a3b50ccee4c05?d=identicon&s=25 Dark Ambient (Guest)
on 2006-06-09 19:21
(Received via mailing list)
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
1b6ed15a6126e1d5ef4d7d15550f30bb?d=identicon&s=25 François Montel (zerohalo)
on 2006-06-09 19:29
Dark Ambient 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.
B780ee0ee1480454a85df58536702f63?d=identicon&s=25 Alder Green (Guest)
on 2006-06-09 19:30
(Received via mailing list)
On 6/9/06, Dark Ambient <sambient@gmail.com> 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.
620c12639078ea2dde8a3b50ccee4c05?d=identicon&s=25 Dark Ambient (Guest)
on 2006-06-09 19:37
(Received via mailing list)
It must be missing then from my configuration.  I either get nothing or
a
load error.

Stuart
620c12639078ea2dde8a3b50ccee4c05?d=identicon&s=25 Dark Ambient (Guest)
on 2006-06-09 19:43
(Received via mailing list)
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
39c5254d0a798765f37ac215fa6e0fc7?d=identicon&s=25 Curtis Spendlove (cuspendlove)
on 2006-06-09 19:44
(Received via mailing list)
On 6/9/06, Dark Ambient <sambient@gmail.com> 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
B780ee0ee1480454a85df58536702f63?d=identicon&s=25 Alder Green (Guest)
on 2006-06-09 19:47
(Received via mailing list)
On 6/9/06, Dark Ambient <sambient@gmail.com> wrote:
>
> > > On 6/9/06, Dark Ambient < sambient@gmail.com> 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
> > > > > > > Rails@lists.rubyonrails.org
> > > > > >
> > > > >
> > > Yes. script/console is very much like IRB. You type ruby expressions
> >
> >
>
>
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>

/ is not standard Win32 notation. Try

ruby script\console
34a7615f38496a5dafbb3e6b721c435e?d=identicon&s=25 Mohit Sindhwani (Guest)
on 2006-06-09 19:50
(Received via mailing list)
Dark Ambient 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.
39c5254d0a798765f37ac215fa6e0fc7?d=identicon&s=25 Curtis Spendlove (cuspendlove)
on 2006-06-09 19:50
(Received via mailing list)
On 6/9/06, Dark Ambient <sambient@gmail.com> 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
620c12639078ea2dde8a3b50ccee4c05?d=identicon&s=25 Dark Ambient (Guest)
on 2006-06-09 19:53
(Received via mailing list)
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
39c5254d0a798765f37ac215fa6e0fc7?d=identicon&s=25 Curtis Spendlove (cuspendlove)
on 2006-06-09 20:03
(Received via mailing list)
On 6/9/06, Dark Ambient <sambient@gmail.com> 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
620c12639078ea2dde8a3b50ccee4c05?d=identicon&s=25 Dark Ambient (Guest)
on 2006-06-09 20:51
(Received via mailing list)
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
B780ee0ee1480454a85df58536702f63?d=identicon&s=25 Alder Green (Guest)
on 2006-06-09 20:58
(Received via mailing list)
On 6/9/06, Dark Ambient <sambient@gmail.com> 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.
620c12639078ea2dde8a3b50ccee4c05?d=identicon&s=25 Dark Ambient (Guest)
on 2006-06-09 21:04
(Received via mailing list)
My apologies Alder, thank you !

Stuart
This topic is locked and can not be replied to.