Can't start a new rails app - ruby-on-rails

When I try to start a new rails app, I get this notification:
"Can't initialize a new Rails application within the directory of another, please Type 'rails' for help."
I read that I may have to empty some directory because there may already be another rails app created. I'm not sure how to do this and start over.

cd ~
cd ProjectsDir # <= Wherever you save your projects
rails new project
cd project
rails generate ...

typing cd .. means going backwards in the directory you're in ...
for example, you're in this_directory, and it's on desktop ...
so, typing cd .. while in this_directory means that you're back on desktop directory now ...
as for the current directory that you're in, don't worry about it ...
just go backwards, and when outside of it, you can delete that directory as you wish, or leave it alone.
type "rails new name_of_app" to start a new rails project ...
and of course, type cd name_of_app to go into the directory of your new rails project.
let us know if you need further clarification ...

cd ../
rails new i_am_in_new_directory

Related

Previous Ruby on Rails application in Cloud9 running on server

I'm new to Ruby on Rails and working through some tutorials, using Cloud9 as an IDE. I recently switched to making a second app only to find that the first one runs on the server available for preview. I have tried starting the new app with $ rails server -b $IP -p $PORT. I have tried stopping the server on the first app with Ctrl + C in the command box. None of this is doing anything. The first application is the only one that displays.
Can someone please explain what is going on? How do I associate the base URL in Preview with the one set in the routing of my new application and why isn't this being done automatically?
Okay, I think the following will work on C9. But personally, I still think separate workspaces would work best.
Create a new project in C9, this will create a new workspace for you. While the folder tree will display the name of your project, the terminal will display ~/workspace. The two are synonymous (for now). This will be your first rails project.
To create a second project within the same C9 space, do the following:
In terminal, cd .. to go up one level. This should take you to the root ~ directory.
Type rails new <name-of-second-project> to create a new project.
At the top of the folder tree, click on the gear wheel. Unselect Show Root File System and Select Show Home in Favorites.
If you look at your folder tree now, you should see both of your rails projects. The first is listed as workspace and the second is whatever you named your second project.
If you want to rename workspace to match the actual name of your project, mv workspace <name-of-first-project>.
That's pretty much it. You can now navigate into each folder and treat it as a separate rails project. When using rails s -b $IP -p $PORT in the terminal, just make sure you're in the correct directory, depending on which project you want to run the server for and it'll work.

Can not create rails apps anymore under Ubuntu

I have a problem with all my three! Ubuntu systems. I can't create any Rails projects anymore with the following command
rails new abcde
I get the following error message.
Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first
I know the error message is really clear, I googled and checked all the entries here on StackOverflow. No one had another explanation other than there is a project in a parent folder, which is not the case in my systems!
I checked all folders back to root for any hidden files resembling a rails project. Nothing! I even created a new folder under root /projects and tried to create a project in there, same error. I don't know what to do anymore, I have the same problem on all three of my Ubuntu computers. Has anyone ever had this problem and could fix it? What could be another cause of this. Because there is no project in any of parent folders.
The only possible solution for me is, that there is maybe a PATH variable for Rails that I don't know about and there is maybe a project in there?
SUGGESTIONS:
0) I'm assuming you're typing these commands from a console window, and not executing a shell script, shortcut, or "something else". Correct?
1) Please update your post with the following: ruby -v; rails -v (Ruby and Rails version info)
2) Please try another test project, and copy/paste any error or warning messages you see:
cd /tmp
rails new abc -f
<= another test "rails new", with "--force" option
3) Assuming you've installed RVM, and assuming your "rails new" is calling "run bundle install", then also make sure your user is a member of the "rvm" group:
sudo usermod -G rvm -a MYUSER
4) If you haven't already, please also look at these links:
can't initialize a new rails application within the directory of another
Problems with RVM and Rails when creating new app

How do I save a ruby file? (error)

I am receiving the error No such file or directory in my command line and I think it's because I am not saving the ruby files somewhere specific. All I did was create a random folder where I would save my ruby files.
Do I need to save my scripts in the original ruby folder? Thanks!
** This is Windows 7.
More info -
All I did was make a simple file named "Matz.rb" because I'm currently reading the O'reilly Ruby book. In my code all I wrote was puts "Hello Matz". I saved this on my desktop. When I go to the command line it and I write ruby matz.rb it says "ruby: No such file or directory -- matz.rb " Please help :(
If this has something to do with PATH or shells, I honestly have no idea what those really are because I just started coding last night.
You are most likely not in the right folder. You somehow need to tell the ruby interpreter where it is looking for the file.
Either make sure you're in the right folder - the cd command allows you to change location:
cd C:\Users\Username\Desktop
ruby Matz.rb
or specify the path explicitly:
ruby C:\Users\Username\Desktop\Matz.rb
By default, the ruby interpreter will look in your current directory (the location shown in your prompt) for whatever filename you give it.
Edit: I'll attempt to explain what I mean step-by-step.
When you initially open the command prompt, it will indicate what folder you are in (your "current working directory") in the prompt:
C:\Users\YourUsername >
In the above example, you are working in the C:\Users\YourUsername folder.
You can move directories using the cd command. For example, typing cd Desktop moves you into the folder called Desktop, assuming such a folder exists in your current location
You can move to another folder outside your current folder by specifying explicitly where you want to be: cd C:\Another\Place
When you run a ruby command such as ruby Matz.rb, the system knows how to find the ruby program because the installer placed its location into the PATH environment variable. Don't worry about this too much, this just explains the "magic" by which it knows what ruby means, no matter where you are.
Ruby finds the file you specify (in the above example, Matz.rb) by looking in the current directory. To re-iterate, it is looking in whatever folder is written right there in your prompt.
You can tell ruby to look outside the current folder by specifying the full path (as shown in the answer above).
To go from a new command window that you've just opened, to typing ruby Matz.rb and having it work, you need to do the following:
Move to the correct directory
Run the command
If we assume your username is alex and you have a folder on your desktop called "rubycode", which contains Matz.rb, you could do this:
Open a command prompt, which will most likely start in C:\Users\Alex
Move to the rubycode folder on your desktop: cd Desktop\rubycode. All subsequent commands will be working from within this folder.
Run the ruby command, specifying the file: ruby Matz.rb
Continue to run ruby commands as you learn ruby.
I hope that makes sense.

Creating a Rails app in workspace directory of Cloud9 IDE

When I run rails new . hoping to create a new Rails app in my workspace directory, rails says:
Invalid application name 567101. Please give a name that does not start with numbers.
How do I get around this? I could just create it within the top level directory, but that seems inelegant. When you create a workspace and select "Rails" for the type it sets up the app nicely in the right place, but I want to set up a Rails 4 app, so that's not an option.
I was just trying to figure this out myself. What I ended up doing is creating a symbolic link to the numbered directory named rails_app. I was then able to do a rails new and have it create the application.
First
cd ~/
Then
ln -s ./567101 ./rails_app
Then
rails new ./rails_app

"Can't initialize a new Rails application within the directory of another, please Type 'rails' for help."

I'm just starting out with rails and I'm practicing the basic ruby commands, one of which is the rails new myproject command.
My projects are under the Aptana workspace directory where I've used the command line and Aptana both to create projects there. After a few creations and rails s commands and deletions, I've started getting this error message when I try to generate a new rails project:
"Can't initialize a new Rails application within the directory of
another, please Type 'rails' for help."
This doesn't just happen when I create a new project (rails new myproject) under the Aptana workspace directory, but also when I use the command rails new . directly inside the workspace directory. Can someone explain to me what I need to do to flush rails so it knows I don't have a project there anymore? What did I do to make this happen?
I don't remember what rails looking for. The quickest way to solve this issue is to completely empty the affected directory.
Most likely there are some hidden files or directories which prevents rails from creating a new project. Look at that with ls -a probably there is a .bundle folder inside that dir.
I got same problem since I failed to create rails project. I tried to remove Aptana plug-in and Eclipe that include ./eclipse, ./metadata but not sloved the problem until I removed Ruby and Devkit and reinstall them again.
So, I think the root cause may in Devkit or Ruby. The problem work out after I reinstall Ruby(rubyinstaller-2.2.3-x64.exe) and DevKit(DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe).
If you are under Windows, you must install Aptana Studio as administrator or it will not work properly. Uninstall and install it as administrator and the terminal folder will be set correctly

Resources