4

当我输入:

$ rails server

我得到这个返回并输入了rails命令:

Usage:
  rails new APP_PATH [options]

Options:
  [--edge]                   # Setup the application with Gemfile pointing to Rails repository
  [--dev]                    # Setup the application with Gemfile pointing to your Rails checkout
  -G, [--skip-git]               # Skip Git ignores and keeps
  -m, [--template=TEMPLATE]      # Path to an application template (can be a filesystem path or URL)
  -b, [--builder=BUILDER]        # Path to a application builder (can be a filesystem path or URL)
      [--old-style-hash]         # Force using old style hash (:foo => 'bar') on Ruby >= 1.9
      [--skip-gemfile]           # Don't create a Gemfile
  -d, [--database=DATABASE]      # Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite3/frontbase/ibm_db/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc)
                                 # Default: sqlite3
  -O, [--skip-active-record]     # Skip Active Record files
      [--skip-bundle]            # Don't run bundle install
  -T, [--skip-test-unit]         # Skip Test::Unit files
  -S, [--skip-sprockets]         # Skip Sprockets files
  -j, [--javascript=JAVASCRIPT]  # Preconfigure for selected JavaScript library
                                 # Default: jquery
  -J, [--skip-javascript]        # Skip JavaScript files
  -r, [--ruby=PATH]              # Path to the Ruby binary of your choice
                                 # Default: /usr/bin/ruby1.8

Runtime options:
  -s, [--skip]     # Skip files that already exist
  -f, [--force]    # Overwrite files that already exist
  -p, [--pretend]  # Run but do not make any changes
  -q, [--quiet]    # Supress status output

Rails options:
  -h, [--help]     # Show this help message and quit
  -v, [--version]  # Show Rails version number and quit

Description:
    The 'rails new' command creates a new Rails application with a default
    directory structure and configuration at the path you specify.

Example:
rails new ~/Code/Ruby/weblog

This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.

为什么它不启动服务器?对我来说,这似乎是一个 rails helpDoc 或类似的东西。类似的情况也发生在:

$ rails generate

我能做些什么来让这些命令正确启动...

我在 Ubuntu 上使用 Rails 版本 3.1.3。

顺便说一句:我从 myapp 的目录中输入这些,即

chuckles@.......:~/Blog/new$

我确实通过运行来启动服务器:

$ script/server

来自/新/

4

5 回答 5

3

我有这个问题。结果我创建了一个 gemset 来与我的应用程序一起使用,然后当我切换到终端中的 app 文件夹时,它恢复为不支持我的应用程序的默认 gemset。

您可以通过以下方式检查您使用的宝石集

rvm gemset list

因此,在我的应用程序文件夹中,我使用切换到了适当的 gemset。

rvm gemset use [your gemset name]

然后

bundle install

更新 gem 文件。

之后一切正常。

于 2014-04-08T18:57:48.650 回答
2

If you have 'script/server', then you probably have rails 2.x application, instead of 3.x. Make sure (rails -v) that you run rails 3.x.x gem, instead of 2.x.

EDIT:

I wasn't clear enough probably. From informations you provided I see:

  • you have rails 3.x gem, and it shows you help screen, because it can't find Rails 3.x application
  • you have application generated by rails 2.x gem (you have script/server script, and you can verify that your application is for older rails by looking at config/environment.rb file)

This combination won't work. You need to do something with it. If you need this old application, then you could uninstall rails 3.x gem and install 2.x verison. It would be even better if you could migrate this application to run with bundler (then you don't need to uninstall rails 3.x gem), but if it's not possible, you can take a look at rvm's gemsets.

What I do when I need to start old application:

  1. rvm use ree - if my application uses Ruby Enterprise Edition on server, otherwise rvm use [ruby version here], depending which version
  2. rvm gemset create [application name here] - to make gemset specific for this application
  3. rvm alias create [application name here] ree@[gemset name here] - to make sure I can get back to this gemset quick
  4. rvm use [alias name here] - to switch to application ruby-gemset combination
  5. install all gems required by application (ask other developers which versions should you use and how to install them

Then whenever I go back to developing this application:

  1. rvm use [alias name here]
  2. ./script/server - to start application

You also need to look for tutorial and documentation for Rails 2.x if you want to develop with this version.

于 2011-12-03T23:03:33.513 回答
1

您只能从现有的 rails 项目文件夹中运行这些命令。查看输出的底部,它为您提供了一个示例命令来创建 rails 项目的骨架结构。

或者,通过本教程运行 http://guides.rubyonrails.org/getting_started.html

于 2011-12-03T22:42:24.823 回答
0

您需要在 rails 项目目录中才能运行这些命令。首先,创建一个新项目:

rails new myapp

然后你可以进入它并运行服务器或其他命令。

cd myapp
rails server
于 2011-12-03T22:42:22.487 回答
0

检查 rails app 根目录中的 bin 目录,我已将其删除,这对我造成了问题。创建一个 bin 目录并至少复制这些文件。

捆绑轨耙

来自任何其他 Rails 项目。

于 2014-10-10T17:47:00.053 回答