Starting script/console for Ruby on Rails with Windows - ruby-on-rails

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.

Related

After installing tailwindcss for ruby should I skip the following suggestions/warnings:

I tried to complete the first suggestion by typing
ruby
rails bin/dev
but I was not able to get an output (The terminal showed no output )
then I realized my code was wrong so I tried once again and typed:
rails create bin/dev
But it showed me an error and said "rails aborted!
Don't know how to build task 'create' (See the list of available tasks with rails --tasks)
Did you mean? db:create"
Then I tried the other command by typing rails in front of it but that didn't work either.
So even though my app works should I bother to solve this warning or skip past it?
TLDR: You need to build your CSS output on every Tailwind style addition so execute bin/dev in a terminal to start your rails server AND watch for tailwind changes.
Hey! Your screenshot is saying that you have successfully installed Tailwind via the tailwind-rails gem.
The end of the message provides instructions on how to build your Tailwind CSS during local development so that Tailwind styles are output to the CSS and applied to your app on localhost:3000 immediately.
Option 1: (documented in the installation output) In your terminal, execute bin/dev to start your rails server AND watch for tailwind changes. This command uses a library called foreman to run two processes, reading from the Procfile.dev that was created in your project's root directory during tailwind installation.
Option 2: (documented in this section of the README) In your terminal, execute rails s in one terminal window and rails tailwindcss:watch in a different window (separate commands)
Option 1 is simpler and probably recommended.
(Based on your screenshot, you are not on a Mac and your exact command may differ, but these work for me on a macbookpro.)

How would I change the rails project directory?

I am using Ruby on Windows and when I use rails to create a project it puts the folder in my user directory, I'd like to specify another location. How would I do this?
You can specify a full path when you say rails new:
> rails new /some/path/where/you/want/your/app
That should work in Windows just like everywhere else.
You can always say rails --help or rails command --help to get some quick help on using the rails command.
use cd to move to the directory you want it in before generating the project.

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

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

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

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

Resources