2016-08-12 140 views
2

当我转到rails文件夹(我在我的rails应用程序文件夹中)并键入“rails c”或“rails g”时,它会提示:命令:rails console,生成无法识别。错误:无法识别命令'rails'用法:rails COMMAND [ARGS]

错误:命令 '轨道' 无法识别

用法:rails命令[参数]

Usage: spring COMMAND [ARGS]                              

Commands for spring itself:                              

    binstub   Generate spring based binstubs. Use --all to generate a binstub for all known commands. Use --remove to revert.     
    help   Print available commands.                          
    server   Explicitly start a Spring server in the foreground                    
    status   Show current status.                           
    stop   Stop all spring processes for this project.                      

Commands for your application:                             

    rails   Run a rails command. The following sub commands will use spring: console, runner, generate, destroy, test.      
    rake   Runs the rake command                           
Error: Command 'rails' not recognized                            
Usage: rails COMMAND [ARGS]                              

The most common rails commands are:                            
generate Generate new code (short-cut alias: "g")                        
console  Start the Rails console (short-cut alias: "c")                      
server  Start the Rails server (short-cut alias: "s")                      
dbconsole Start a console for the database specified in config/database.yml                 
      (short-cut alias: "db")                            
new   Create a new Rails application. "rails new my_app" creates a                   
      new application called MyApp in "./my_app"                       

In addition to those, there are:                             
destroy  Undo code generated with "generate" (short-cut alias: "d")                   
plugin new Generates skeleton for developing a Rails plugin                     
runner  Run a piece of code in the application environment (short-cut alias: "r")               

All commands can be run with -h (or --help) for more information. 

我运行Linux子系统用于Windows 10,我知道,我知道你看到的Windows,但它是一种.. 。Linux,我用rbenv通过this tutorial安装了Ruby。

+0

好的,我会尝试。但我仍然可以通过“rails新应用程序”创建项目? – truongnm

+1

这可能会帮助你http://stackoverflow.com/questions/21608744/rails-command-error –

回答

6

从您的app文件夹试试这个命令:

rake rails:update:bin 

比如Y更换二进制文件。

我在Windows Linux子系统上使用rails时遇到了同样的问题。我发现这里的建议:

Rails command Error

我尝试过了,它解决了我的问题,所以也许你也是如此。

+0

非常感谢!那帮助了男人 – Liker777