ruby script\generate controller NOT WORKING - ruby-on-rails

I am following this tutorial and I've run the command ruby script\server and successfully started the server.
Now, when I run ruby script\generate controller MyTest, it says
'ruby' is not recognized as an internal or external command..

This error message means
you dont' have ruby installed (It's on page 1 of your tutorial)
or
ruby is not in your PATH . In that case, check if the PATH points to the folder where you have installed ruby (on Windows I think it's PATH)
Edit:
If you look at the screenshots of the 1st page, the path to ruby is specified all the time
"c:\ruby\bin\ruby.exe" "c:\ruby\bin\gem" install rails
I did install it on my netbook - I specified to update my PATH but it didnt. After setting up my path correctly, I could type: gem install rails

Sounds like you either haven't installed ruby or it hasn't been added to your PATH environment variable. Use the link text from this page and make sure you open the cmd.exe console AFTER you installed Ruby.

Related

Rails command not working on Windows command line

I installed Ruby and Rails and set-up the PATH to "C:\Rails\Ruby2.3.0\bin", but when I try to run commands with rails, I get the error message:
The System cannot find the path specified.
I am able to run commands using ruby, and rails works if I use GitBash. How do I make it work on my normal command line?
Had the same problem here, installed the same way. Couldn't even run rails commands on GitBash, only way was going in C:\Rails\Ruby2.3.0\binthrough cmd and typing, for example, ruby rails new projectname. The rails new projectnamewouldn't work even in these conditions.
What I did was going in the Command Prompt with Ruby and Rails and entered gem install rails (which did not work on cmd). I also did gem install bundle. Both installed successfully and that fixed all consoles for me: cmd, GitBash (wasn't working for me), Command Prompt with Ruby and Rails and even cmder works with Rails now.
Hope this helps you.
Cheers.
If it's a simple question of locating the rails executable on Windows, then on later installs that use msys64 instead of DevKit, you'll find rails at the following folder:
c:\msys64\o-rdoc
Add this to your PATH or execute from that folder.
Your path may vary on 32-bit systems or if you changed the default install folder.

"rails new [Blah]" No such file

So I'm new to Ruby and also to Rails. I have recently installed Ruby on Arch Linux.
It was mostly all fine any happy except for a few errors here and there but now when I try initializing a new rails app using rails new AppName I get the error
bash: /home/[username]/.gem/ruby/2.3.0/bin/rails: No such file or directory
I've tried creating a file and directory called rails in but get more errors.
reinstalling rails same outcome
reinstalling ruby same outcome
following any other dependencies at install also leads no wear.
Ask for any info you may need.
Thanks in advance
UPDATE
installing of gems is now stopped by a common error
$ gem install rails
Building native extensions. This could take a while...
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /usr/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.6.8/gem_make.out
and the same when I try install nokogiri
ok first check that you installed both ruby and rails well
ruby -v
and
rails -v
so if you get a respond to that you're all good
go to the place you want to create your folder att
rails new appname
then
cd appname
if that doesn't work try to generate anything
rails generate controller appname
if the generate works then your rails is ok if not then you might want to add the rails to your environment variable path.
You installed ruby on your computer. However the path is not recognized yet on it. To add it you can do this . if you are using windows my computer right click and then chose advanced system settings -> advanced at the bottom environment variables system variables PATH and then add the the path to your ruby bin folder. I am sorry i don't have enough reputation so can't add pictures but reading this will solve your problem
The overall problem is a lack of permissions to /usr/lib/ruby/. This can be fixed with
sudo chmod 777 /usr/lib/ruby

Rails Server is not starting on Windows 10

I am using windows 10. I install Rails and other supporting software via railsinstaller.org website.
Now I go on CMD and writing command rails server but Rails server not starting work. when I open link in firefox http://localhost:3000
Following is snapshot of output when I write rails s in cmd. I have Rails 4.2.5.1 in my PC and using Windows 10
The problem my be caused due to following (Unable to Install gems)
if you are using latest version of ruby installer to install ruby then there are problem for installing nokogiri and ulifier or other gem which needs to compailing in your pc. so you needs to install devkit first. For this please do following:
The download is a self-extracting archive. When you execute the file, it’ll ask you for a destination for the files. Enter a path that has no spaces in it. We recommend something simple, like C:\RubyDevKit\. Click Extract and wait until the process is finished.
Download from here
Next, you need to initialize the DevKit and bind it to your Ruby installation. Open your favorite command line tool and navigate to the folder you extracted the DevKit into.
cd C:\RubyDevKit
Auto-detect Ruby installations and add them to a configuration file for the next step.
ruby dk.rb init
Install the DevKit, binding it to your Ruby installation.
ruby dk.rb install
Now run bundle install
If still problem persist downgrade your ruby or install linux distro.
You need to change your directory to the app root folder.For Example if your app name is 'myapp', then type cd myapp and run rails server with rails s.
Check if the bin/rails file is in place. If not, generate a new sample app, then copy the bin folder to it.
simply add gem "tzinfo-data" to your Gemfile and run bundle install and you are good to goenter image description here

Rails Installer the system can not get the specified path

I have installed rails and ruby with railsinstaller. The problem is, when i run rails command, it gives me: "The system cannot find the path specified."
Tried uninstalling rails and installing it againt, does not help. Ruby commands executes like "ruby -v", "rails -v" doesn`t work.
Have googled,didn`t find solution for windows, that worked.
You need to set your system PATH variable.
To do this go to
My Computer > Properties > Advanced > Environment Variables > System Variables
Click PATH and add the path to Ruby, which will be along the lines of C:\ruby\bin

"rails server" command is not getting recognized

I am new to rails and am following the tutorial posted on the ROR website. Everything is working fine until I try and load up my rails application on the localhost. Every time enter $ rails server I get a long list of possible commands and functions. When I check my localhost:3000 and 127.0.0.1:3000, nothing seems to be connected.
Upon digging deeper, I have tried almost everything everyone else has tried. I am running the command in the same path as my new rails application. Furthermore, when I enter in nonsense after the $ rails command I get the same list of possible commands and functions. So I get the feeling that rails is not recognizing the server command.
Here are my versions:
Ruby 1.9.3 p374
Rails 3.2.11
Why isn't the server command recognized?
First of all you have to move to the project directory and install bundle with the following command:
bundle install
Then start the server:
rails server
I had the same problem. rails server or simply rails s only works when you are in the right directory.
Type pwd (present working directory) to see where you currently are.
Type cd and the rest of the direction to the correct directory.
(for example, "cd workspace/learn-rails")
Type rails server or rails s.
Check http://localhost:3000.
Please exit from terminal and then restart the terminal.
Then check the directory path i.e just type pwd it will show the current directory path.
And if directory is correct on try again running command like bundle install & rails server
I think this should be work.

Resources