[英]typing 'rails console' doesn't start?
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。
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我 cd 进入我的应用程序目录,但 rails 控制台不起作用
Turned out I'd included the bin folder as a symlinked directory in my cap deploy, as follows:结果我将 bin 文件夹作为符号链接目录包含在我的 cap deploy 中,如下所示:
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}设置 :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
... and my bin directory in 'shared' was empty. ...并且我在“共享”中的 bin 目录是空的。
Two fixes:两个修复:
I then re-deployed and it works.然后我重新部署并且它工作。
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 console
的快捷方式
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 [anything]
)时,我会看到一般的rails new
用法输出(正如 Blankman 在原始文件中引用的那样问题)。
The problem was that I had not removed the old Rails 2 scripts from the script
directory.问题是我没有从
script
目录中删除旧的 Rails 2 脚本。 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.在删除
script
目录中的所有内容并添加在每个新的 Rails 3 应用程序中自动生成的script/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.为了获取
script/rails
文件的最新内容,生成一个新应用程序并将该文件复制到您正在升级的 Rails 2 应用程序中。 As of Rails 3.0.7, here's what's in this file:从 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'
当我将 Rails 2 升级到 3 时遇到了这个问题,并且能够按照 Nick 所说的进行修复,然后还运行bundle exec rails console production
。
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.在 Rails 2.3.x 中,该命令是给定 Rails 应用程序目录中的
script/console
,用于启动 Ruby 控制台,并将默认 Rails 环境加载到内存中。 Not sure if Rails 3.0 is the same or not.不确定 Rails 3.0 是否相同。
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...
are you in a rails 3 app directory?你在 rails 3 app 目录吗?
do you have multiple versions of rails installed?您是否安装了多个版本的导轨?
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。
You are running the correct command ( rails console
), but you are most likely not in the working directory for this application.您正在运行正确的命令 (
rails console
),但您很可能不在此应用程序的工作目录中。 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 应用程序的根目录(您将在其下方找到
/scripts
、 /app
等),该命令应该可以正常工作。
Note: Using script/console
or ruby script/console
is for earlier versions of Rails.注意:使用
script/console
或ruby script/console
适用于早期版本的 Rails。
在我的情况下bin/rails c
处理了我的应用程序根文件夹
You need two gems "rdoc" and "rb-readline After that add this gems in Gemfile and bundle install
Console is working fine你需要两个 gem "rdoc" 和 "rb-readline 之后在 Gemfile 中添加这个 gems 和
bundle install
控制台工作正常
Arch-linux or Manjaro Arch-linux 或 Manjaro
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.