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.
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.
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.
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.
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.
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.
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…
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
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.
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.
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