This project is archived and is in readonly mode.
Suggestion: Change to create Rails 3.0 apps by `rails init app-name`
Reported by Pyry Jahkola | May 22nd, 2010 @ 01:50 PM
Suggestion
Please consider changing the Rails initialization command from
"rails app-name
" to "rails init
app-name
".
Rationale
Too often it happens that I try to run a Rails command like
"rails s
" accidentally under a non-Rails directory.
That leads to unwished new directories named "s
" or
"console
" etc.
It seems to me, creating new Rails apps doesn't happen too often to oppose adding these additional five (or two, shortcut "i") key presses to the command line syntax.
The changed syntax would be in line with e.g. Git commands.
Proposal for new command line messages
Under a non-Rails directory
- "
rails
" — shows the help message just like now (just change the Usage & Example texts accordingly to "rails init ...
") - "
rails init
" — creates a new Rails 3.0 application in current directory - "
rails init .
" — ditto - "
rails init app-name
" — creates a new Rails 3.0 application under./app-name
- "
rails cmd
" — returns printing something along the following to stdout:This is not a Ruby on Rails project. Did you mean to create one? Use 'rails init cmd' to create a Rails application named "cmd". Type 'rails' for help.
Under a Rails directory
- "
rails
" — shows the help message just like now - "
rails init [arg]
" — prints something like:Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first. Type 'rails' for help.
Comments and changes to this ticket
-
Harri Kauhanen May 22nd, 2010 @ 05:01 PM
+1
Excellent suggestion!
There's fix #8994 to prevent creating projects with name 's', 'db' and so on with Rails 3, but that one is a bit ugly and does not really solve the problem. If you use both Rails 2.3 and Rails 3, you will keep creating those 's' projects for a long time (transition from Rails 2.3 to Rails 3 will certainly take some time). Anyone using rvm (Ruby version manager) knows what I am talking about. Rails 2.3.6 should also include a fix that would warn if you try to create project under name 'init'.
'rails init' also feels much more natural than the current default behavior.
-
vesan May 22nd, 2010 @ 08:19 PM
+1
This is change from how things have worked previously but IMHO change for the better.
-
Rohit Arondekar May 23rd, 2010 @ 11:10 AM
+1 for the change, I've been hit by this same problem too and it would be nice to do rails init app-name. Can somebody start working on a patch?
-
Ryan Bigg May 23rd, 2010 @ 11:26 AM
- State changed from new to open
+1, I've done this twice today!
-
Jeff Kreeftmeijer May 23rd, 2010 @ 12:01 PM
+1
Since the
rails
command handles everything (like generating scaffolds, starting the server and console etc.) in Rails 3,rails appname
to generate an app doesn't feel right anymore. I thinkrails init appname
is much more like the rest of therails
command and it'll keep me from having to remove directories like "s" or "console". Great suggestion! :) -
Justin Baker May 24th, 2010 @ 03:45 AM
+1
This irritates me so much when I do it, everyone seems to do it too.
-
Justin Baker May 24th, 2010 @ 03:54 AM
I have a quick fix that I posted as a gist on github, obviously this probably needs more to see if you're already in a rails app directory, but if you're sick of the accidental app creation then it should work.
-
Rohit Arondekar May 26th, 2010 @ 01:11 PM
- Assigned user set to Mikel Lindsaar
-
Mikel Lindsaar May 26th, 2010 @ 03:26 PM
- Milestone cleared.
OK, thanks everyone, I took Juston's patch and have gone over it with DHH. We are going to make a couple of changes to your patch and then merge into rails/master.
-
Rohit Arondekar May 26th, 2010 @ 04:02 PM
That's awesome news Mikel! Cheers Pyry for bringing it up and Justin for the patch. :)
-
Justin Baker May 26th, 2010 @ 05:46 PM
Documentation/Guides/Tutorials will have to be updated though, but the help message shouldn't be too hard for a user to follow if they run rails testapp after following a guide to create an application before this.
-
Ryan Bigg June 4th, 2010 @ 06:53 AM
Thanks Mikel! Just installing now and will let you know if it goes or blows.
-
Ryan Bigg June 4th, 2010 @ 07:07 AM
The usage of the "rails" command still says
rails APP_PATH [options]
Maybe I'm being picky?
-
Mikel Lindsaar June 4th, 2010 @ 07:25 AM
Really? Where (or when)? I'll fix. I thought I found all of those...
-
Ryan Bigg June 5th, 2010 @ 12:01 AM
- State changed from open to committed
-
Uģis Ozols June 14th, 2010 @ 08:04 AM
After this addition to rails is there a way to generate app with older rails version? In 3.0.0.beta3 I could use rails 2.3.8 app_name
-
Ryan Bigg June 14th, 2010 @ 08:13 AM
You can still do rails _2.3.8_ app_name to generate an app for 2.3.8.
-
Uģis Ozols June 14th, 2010 @ 08:55 AM
Oh I'm sorry... it's working perfectly. Messed up on my end :)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>