I typed this:
我输入了这个:
>rails console
and got this:
得到了这个:
Usage:
rails new APP_PATH [options]
Options:
[--skip-gemfile] # Don't create a Gemfile
-d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db)
# Default: sqlite3
..
..
.
I'm following along the rails tutorial and got stuck on this.
我正在按照rails教程进行操作并且坚持这一点。
I have rails 3.0 installed.
我安装了rails 3.0。
9 个解决方案
#1
33
Are you in the root path of your app when you type $ rails console
?
键入$ rails console时,您是否位于应用程序的根路径中?
Tip: $ rails c
is a shortcut for $ rails console
提示:$ rails c是$ rails控制台的快捷方式
#2
33
In case anyone else hits this, my symptoms were:
如果其他人遇到这个,我的症状是:
I'd deployed my application with Capistrano 3
我用Capistrano 3部署了我的应用程序
I cd'd into my application directory, and rails console didn't work
我进入了我的应用程序目录,rails控制台无效
Turned out I'd included the bin folder as a symlinked directory in my cap deploy, as follows:
原来我在bin部署中将bin文件夹作为符号链接目录包含在内,如下所示:
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set:linked_dirs,%w {log tmp / pids tmp / cache tmp / sockets vendor / bundle public / system}
... and my bin directory in 'shared' was empty.
...并且'shared'中的bin目录为空。
Two fixes:
两个修复:
- Ensure your linked bin directory has the correct contents (have a look inside your #{RAILS_ROOT}/bin directory for what this is, OR
- 确保链接的bin目录具有正确的内容(查看#{RAILS_ROOT} / bin目录,了解其内容,或者
- Don't symlink bin
- 没有符号链接bin
I then re-deployed and it works.
我然后重新部署,它的工作原理。
#3
9
I just ran into this same problem while upgrading a Rails 2 app to Rails 3. When running rails console
(or really rails [anything]
) in my app's root directory, I would see general rails new
usage output (as Blankman referenced in the original question).
我在将Rails 2应用程序升级到Rails 3时遇到了同样的问题。在我的应用程序的根目录中运行rails console(或者真正的rails [任何])时,我会看到一般rails新的使用输出(如原始中引用的Blankman)题)。
The problem was that I had not removed the old Rails 2 scripts from the script
directory. After removing everything in the script
directory and adding the script/rails
file that is auto-generated in each new Rails 3 app, the rails
command now works as expected.
问题是我没有从脚本目录中删除旧的Rails 2脚本。删除脚本目录中的所有内容并添加在每个新Rails 3应用程序中自动生成的脚本/ rails文件后,rails命令现在可以按预期工作。
In order to get the latest contents of the script/rails
file, generate a new app and copy the file into your Rails 2 app that you're upgrading. As of Rails 3.0.7, here's what's in this file:
要获取脚本/ rails文件的最新内容,请生成一个新应用程序并将该文件复制到您正在升级的Rails 2应用程序中。从Rails 3.0.7开始,这里是这个文件中的内容:
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
#4
7
I had this problem when I upgraded Rails 2 to 3 and was able to fix it by doing what Nick said, then also running bundle exec rails console production
.
当我将Rails 2升级到3并且能够通过做Nick所说的那样修复它,然后还运行bundle exec rails console生产时,我遇到了这个问题。
#5
3
In Rails 2.3.x the command is script/console
within a given Rails application directory to start a Ruby console with the default Rails environment loaded into memory. Not sure if Rails 3.0 is the same or not.
在Rails 2.3.x中,命令是给定Rails应用程序目录中的脚本/控制台,以启动Ruby控制台,并将默认的Rails环境加载到内存中。不确定Rails 3.0是否相同。
#6
2
You need to into the project directory and command rails console
eg:
您需要进入项目目录并命令rails console,例如:
D:\workspace\>rails blog
D:\workspace\>cd blog
D:\workspace\blog\> rails c
loading en...
#7
1
are you in a rails 3 app directory?
你在rails 3应用程序目录中吗?
do you have multiple versions of rails installed?
你有多个版本的rails安装?
try checking 'which rails', and make sure this is a rails 3 executable you are running - that usage looks like rails 2.x.
尝试检查'which rails',并确保这是您正在运行的rails 3可执行文件 - 该用法看起来像rails 2.x.
#8
1
You are running the correct command (rails console
), but you are most likely not in the working directory for this application. Change directory to the root of your rails application (beneath which you will find /scripts
, /app
, etc.), and the command should work as desired.
您正在运行正确的命令(rails console),但您很可能不在此应用程序的工作目录中。将目录更改为rails应用程序的根目录(在其下方将找到/ scripts,/ app等),命令应该可以正常工作。
Note: Using script/console
or ruby script/console
is for earlier versions of Rails.
注意:使用脚本/控制台或ruby脚本/控制台适用于早期版本的Rails。
#9
0
In my case bin/rails c
worked off my app root folder
在我的情况下,bin / rails c处理了我的app根文件夹
#1
33
Are you in the root path of your app when you type $ rails console
?
键入$ rails console时,您是否位于应用程序的根路径中?
Tip: $ rails c
is a shortcut for $ rails console
提示:$ rails c是$ rails控制台的快捷方式
#2
33
In case anyone else hits this, my symptoms were:
如果其他人遇到这个,我的症状是:
I'd deployed my application with Capistrano 3
我用Capistrano 3部署了我的应用程序
I cd'd into my application directory, and rails console didn't work
我进入了我的应用程序目录,rails控制台无效
Turned out I'd included the bin folder as a symlinked directory in my cap deploy, as follows:
原来我在bin部署中将bin文件夹作为符号链接目录包含在内,如下所示:
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set:linked_dirs,%w {log tmp / pids tmp / cache tmp / sockets vendor / bundle public / system}
... and my bin directory in 'shared' was empty.
...并且'shared'中的bin目录为空。
Two fixes:
两个修复:
- Ensure your linked bin directory has the correct contents (have a look inside your #{RAILS_ROOT}/bin directory for what this is, OR
- 确保链接的bin目录具有正确的内容(查看#{RAILS_ROOT} / bin目录,了解其内容,或者
- Don't symlink bin
- 没有符号链接bin
I then re-deployed and it works.
我然后重新部署,它的工作原理。
#3
9
I just ran into this same problem while upgrading a Rails 2 app to Rails 3. When running rails console
(or really rails [anything]
) in my app's root directory, I would see general rails new
usage output (as Blankman referenced in the original question).
我在将Rails 2应用程序升级到Rails 3时遇到了同样的问题。在我的应用程序的根目录中运行rails console(或者真正的rails [任何])时,我会看到一般rails新的使用输出(如原始中引用的Blankman)题)。
The problem was that I had not removed the old Rails 2 scripts from the script
directory. After removing everything in the script
directory and adding the script/rails
file that is auto-generated in each new Rails 3 app, the rails
command now works as expected.
问题是我没有从脚本目录中删除旧的Rails 2脚本。删除脚本目录中的所有内容并添加在每个新Rails 3应用程序中自动生成的脚本/ rails文件后,rails命令现在可以按预期工作。
In order to get the latest contents of the script/rails
file, generate a new app and copy the file into your Rails 2 app that you're upgrading. As of Rails 3.0.7, here's what's in this file:
要获取脚本/ rails文件的最新内容,请生成一个新应用程序并将该文件复制到您正在升级的Rails 2应用程序中。从Rails 3.0.7开始,这里是这个文件中的内容:
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
#4
7
I had this problem when I upgraded Rails 2 to 3 and was able to fix it by doing what Nick said, then also running bundle exec rails console production
.
当我将Rails 2升级到3并且能够通过做Nick所说的那样修复它,然后还运行bundle exec rails console生产时,我遇到了这个问题。
#5
3
In Rails 2.3.x the command is script/console
within a given Rails application directory to start a Ruby console with the default Rails environment loaded into memory. Not sure if Rails 3.0 is the same or not.
在Rails 2.3.x中,命令是给定Rails应用程序目录中的脚本/控制台,以启动Ruby控制台,并将默认的Rails环境加载到内存中。不确定Rails 3.0是否相同。
#6
2
You need to into the project directory and command rails console
eg:
您需要进入项目目录并命令rails console,例如:
D:\workspace\>rails blog
D:\workspace\>cd blog
D:\workspace\blog\> rails c
loading en...
#7
1
are you in a rails 3 app directory?
你在rails 3应用程序目录中吗?
do you have multiple versions of rails installed?
你有多个版本的rails安装?
try checking 'which rails', and make sure this is a rails 3 executable you are running - that usage looks like rails 2.x.
尝试检查'which rails',并确保这是您正在运行的rails 3可执行文件 - 该用法看起来像rails 2.x.
#8
1
You are running the correct command (rails console
), but you are most likely not in the working directory for this application. Change directory to the root of your rails application (beneath which you will find /scripts
, /app
, etc.), and the command should work as desired.
您正在运行正确的命令(rails console),但您很可能不在此应用程序的工作目录中。将目录更改为rails应用程序的根目录(在其下方将找到/ scripts,/ app等),命令应该可以正常工作。
Note: Using script/console
or ruby script/console
is for earlier versions of Rails.
注意:使用脚本/控制台或ruby脚本/控制台适用于早期版本的Rails。
#9
0
In my case bin/rails c
worked off my app root folder
在我的情况下,bin / rails c处理了我的app根文件夹