How would I change the rails project directory? - ruby-on-rails

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.

Related

Rails project can not be created

I want to create a Rail project named Pierre with Aptana Studio 3 but it's written :
Pierre#PC-Pierre ~
$ rails new .
Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.
Type 'rails' for help.
I have joined a screenshot of the repository where I created my project. Could someone help me to deal with that ?
Seems like the issue you are describing comes from Aptana and not Rails. Create the App from cmd and then import it into Aptana like so: https://superuser.com/questions/324183/how-can-i-import-an-existing-project-in-aptana-without-moving-the-files

Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first

I'm getting this error:
Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first
But I'm not in a rails directory, I'm on the desktop. There's no .bundle files anywhere to be found. Any ideas?
cd bin/
rm -rf rails
This fixed my problem. I was also getting the same error message
"Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.
Type 'rails' for help."
I was struggling with this over the weekend, but after lots of prodding and poking got it to work.
The problem for me was that Aptana (I believe) created a second rails script in my local bin directory (~/bin) which was called instead of the system script. This local version was older than /usr/local/bin/rails. After moving aside ~/bin/rails, "rails new fred" worked as expected.
Try creating a new folder or rails app in root folder, under ~/
I was having the same problem this morning and that's because rails was already been there while i was creating my application.
To remove the error just go to bin folder of your application and remove the rails folder, and try to create new rails application in your planned folder using rails new app_name.

Creating new rails app dumps all the information in root directory

So I am having a strange issue. When I do rails new ~ whatever it creates all the files put slews them across my root directory in OSX. Even when I have specified to start in a different directory, it always places it all there. What am I doing wrong?
Thanks
Are you literally typing:
rails new ~ whatever
the rails command has the following usage:
rails new APP_PATH [options]
So it looks to me like you're trying to create a new rails app in your home dir. Try:
rails new whatever

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

NetBeans hangs up while creating a Rails project

I'm using NetBeans and I'm trying to create a new Rails project trought the wizard, so while I click the finish button, it creates the folder structure but the wizard never finish working and doesn't show nothing on the Projects view.
It just happens when I set up a Sqlite3 DB.
I'm using Rails 3.0.7
Can someone help me?
I have always struggled to create Rails projects using the internal netbeans wizard. Usually I find it easier to create the rails app from the command line:
rails your_app_name
This will create a new folder your_app_name in your current location, and then I create a new project within Netbeans by selecting the 'Ruby on Rails Application with Existing sources' option. And select the freshly created your_app_name folder for the Project folder.
I have found Netbeans to be less reliable with rails 3+ applications than the 2+ and find that run most rails commands directly from the terminal/command prompt.
do you have sqlite3 installed? Anyways people will be able to help you if you can post the netbeans log. Go to the command line and run netbeans from the command line. Then you can see a lot of output/logging info.

Resources