How can I run Rails "script/[xyz]" commands on Windows? - ruby-on-rails

I am used to doing Rails development work on a Mac. However, now other developers will be working with me and they use Windows, both XP and Vista. I am trying to figure out the Windows environment so I can help them.
In OS X and Linux you have this kind of thing...
$ cd [Rails project root]
$ script/console
Tried it on Windows but all I got was "'script' is not recognized as an internal or external command...etc."
What is the Windows equivalent?

ruby script/whatever
That should do it for you.

Get into your rails directory, then type:
ruby script/(your command)
Make sure that you have the path to ruby on your path - otherwise you need to do:
(path to ruby)/ruby script/(your command)

Does:
c:\railsproject\> ruby script/console
work for you?

Have you tried issuing ruby script\console ? (Windows uses backslashes as path delimeters instead of foreslashes and doesn't support shebang syntax.)

rails path/to/your/new/application
cd path/to/your/new/application
ruby script/server
Check this out: http://rubyonrails.org/download

Related

How can i type linux commands after using ruby script/server to set up a local server?

I am new to programming and ruby on rails. This question may be a little dumb.
After I set up a server(basically an empty one) in Ubuntu terminal using the "ruby script/server" command. My "usersname:~$" label is gone and the only way I know how to type in terminal again is to shutdown the server or Ctril + z. How do i keep the server running while I try to edit the contents of my server(such as writing controller)?
Use ruby script/server &. Adding & will run the server in bacground
Open another terminal ,
cd app_directory
and run any command you want. As a result your commands won't be affected due to page load

Instant rails 2.0 doesn't start the server in windows 7

I have use the instant rails. In ruby console window I have created a new ruby rails application but I can't run the file server from the script folder.
To run it i used script/server command. it says "server" is not recognized internal or external command.
I am not running windows as administration
I personally don't know what your environment looks like but it looks like instant rails isn't maintained anymore (discontinued in 2007).
That being said it might be that you're not running the script using a Ruby executable.
I would personally suggest switching to RailsInstaller or RubyStack.

cannot run rails server command for already created project

I have got an application which was zipped and I unzipped the files and it gave me a folder with all the required structure of a rails application. But when I am going inside the directory and running the rails server command, its not doing anything, but showing me the list of options rails command can do. What would have been the problem?
thanks
Maybe this will help from app folder try:
ruby script/rails server
As explained by Dave Isaacs, Showing the list of options is what the rails command does when it is executed outside the context of an application (i.e., not in the application directories).
Type the full command, including the /script path to the CLI.
script/rails server
instead of
rails server
where script is the path to the rails command that, in a Rails 3 application, lives in the script folder.
I would assume that the application you got was written with rails 2.x. In that case, you have to start it with
script/server

Starting script/console for Ruby on Rails with Windows

I'm having trouble starting script/console.
I've tried cd'ing into the project root ("C:\MyProject") then typing "script/console" and I get this:
'script' is not recognized as an internal or external command,
operable program or batch file.
And when I type "ruby script/console" I get this:
Ruby: No such file or directory -- script/console (LoadError)
Any ideas? Should I be running these commands from the root? Thanks.
The usage ruby script/console is present in Rails 2.3.x versions and older. I believe you installed Rails 3.x which deprecated that command.
You need to use now rails console or rails c (short version) from the application directory.
Better pay a visit to the Rails guides for all the other changes.
In Windows you need to use backslash (\) instead of the regular slash (/).
script\console should work for you, provided you use Rails 2.x. On Rails 3 use rails console as mentioned by other coleagues.
Is ruby installed? Is it in your PATH?
http://www.ruby-lang.org/en/downloads/
When it installs, look for the checkbox to add ruby to your path.
If it's already installed, then (on Windows 7), go to the Start Orb, type "path" and click on "Edit the system environment variables". Click on "Environment Variables". In the bottom list scroll down to "Path". Select "Path" and click "Edit". At the end of the "variable value" list put another semi-colon and the path to your ruby.exe.
EG: ";C:\Ruby\bin"
DO NOT delete anything else from that field.

How to begin with Ruby on Rails using Windows

I've tried downloading the Rails package and installing it on Windows, but have no idea to make it work.
I have had some experience with this commbination:
PHP 4.x + 5.x (Windows)
LIGHTTPD (Windows)
Connecting to a Firebird Database (Windows)
Can anybody enlighten me?
I've gotten Rails up and running on Windows just following the instructions on the RoR website. To paraphrase:
Download Ruby Windows installer from here. I recommend this one.
Execute the .exe [ruby186-26.exe]
Verify your Windows environment variables now includes C:\ruby\bin in the PATH variable. (My Computer -> Properties -> Advanced -> Environment Variables). If it's not there, add it.
Download Ruby Gems from here.
Extract the zip [rubygems-1.3.0.zip] to a temporary directory.
Open a command window and cd to the temp directory.
Type ruby setup.rb in the command window and hit enter.
After that from the command window type gem install rails
Boom! You have rails on windows.
I've heard good things about Instant Rails I've avoided it though. I highly recommend RadRails for Eclipse. I do all my RoR development in Windows using RadRails to connect to a MySQL database.
Either try Instant Rails, which hasn't been updated in a while.
Or try this tutorial and install everything yourself: http://beans.seartipy.com/2008/06/09/setting-up-rails-development-environment-on-windows-vistaxp/
If you're really beginning and have no special attachment to the stuff you've downloaded, try getting the latest Netbeans (v6.1) which comes with Ruby and Rails build in. Its massively simple to install and get running. (A double click install). Then, once you've done that do a "File > New Project > Ruby > Ruby On Rails Application", press F6 and you'll be looking at the start page of your first Rails App.
To get to grips with it all, I'd suggest Sang Shin's free Ruby On Rails course. Its been running a while, but its free, is hands on, has some excellent material, and covers a great deal. I'm doing it and have learned a lot about Rails and Ruby also.
HTH
I use Heroku this is the Signup page for all my Rails Development
You don't have to install or set up anything and you are up and running Fast.
Also, this is a good tutorial for setting up Instant Rails on Vista:
You should really consider just install a Virtual Machine using VMWare if possible. You can still get start with Windows, but you could come across a lot of hiccups on various packages you want to use. I was from Windows too... now I switched myself to a mac and never looked back....
The point is, Ruby runs just a lot better on any POSIX other than using Windows, so its better not to try forcing anything suppose to work properly on one platform on another one. Practically, you will NEVER consider hosting a rails application in Windows (similarly, I doubted if you should ever consider hosting a PHP app in Windows too... you are just putting more cost to hurt your own feet by doing so...)
Another possibility is try to get Ubuntu setup on a USB memory/ hard drive and boot using that when you want to play Rails, slightly problematic, but better performance.
NetBeans as suggested as beginner IDE is good. Although if you get start properly with a good book (Pragmatic defacto Rails book 3rd edition is a good choice, you will never put that one down even after so long as the references are just too useful). Alternatively Rails Guide is something you shouldn't miss.
These are the best tutorials that I have seen for setting up rails on Windows.
Xp: http://www.buildingwebapps.com/articles/6467-setting-up-rails-on-windows-xp
Vista: http://www.buildingwebapps.com/articles/6491-setting-up-rails-on-windows-vista
I used this tutorial just yesterday and it worked well. BUT you need to install RubyGems yourself, after installing Ruby and before installing Rails. I found this guide helpful for RubyGems installation.
I was not able to use an environment variable to set up the http proxy; instead I must pass that as a param on the CL when installing gems (-p [myproxy].[mysite]:[port])
Late to the party, but could you try this tutorial instead?
Getting Started with Rails and MySQL
Two observations:
--source http://gems.rubyinstaller.org is no longer needed. remove that part from the command
Install latest RC1 for either 1.9.1 or 1.8.6 from here
Hope that helps
Here's some tools that have helped me in Windows for general RoR development
TextMate-like editor: http://www.e-texteditor.com/
Multi-tab SSH client: http://www.vandyke.com/products/securecrt/index.html
Full featured UNIX shell (including git): http://code.google.com/p/msysgit/
I just followed this tutorial, and it worked great the first time, and gives steps to take if you encounter common errors. I HIGHLY recommend it. it's one of the best tutorials I've ever gone through. I'm an ASP .NET guy, and I had no trouble.
My suggestion is to begin with a microframework. Something like Sinatra. You can move to Rails / Merb afterwards.
checkout Rails Windows Installer
it installs :
Ruby 1.8.7-p330
Rails 3.0.3
Git 1.7.3.1
Sqlite 3.7.3
DevKit
Rubystack is a free, all-in-one installer for Windows that installs Apache, MySQL, Ruby, Rails and all other third-party libraries typically used on a development environment (such as Imagemagick). We include PHP as well, but no lighttpd

Resources