4

私が入るとき:

$ rails server

これが返され、レールコマンドが入力されました:

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

/new/から

4

5 に答える 5

2

「スクリプト/サーバー」がある場合は、3.x ではなく、おそらく Rails 2.x アプリケーションを使用しています。rails -vRails 2.x ではなく 3.xx gem を実行していることを確認してください ( )。

編集

私はおそらく十分に明確ではありませんでした。あなたが提供した情報から、私は見ます:

  • Rails 3.x gem があり、Rails 3.x アプリケーションが見つからないため、ヘルプ画面が表示されます。
  • Rails 2.x gem によって生成されたアプリケーションがある (script/serverスクリプトがあり、ファイルを調べることでアプリケーションが古いレール用であることを確認できconfig/environment.rbます)

この組み合わせはうまくいきません。あなたはそれで何かをする必要があります。この古いアプリケーションが必要な場合は、Rails 3.x gem をアンインストールして 2.x バージョンをインストールできます。このアプリケーションを移行して bundler で実行できるようになれば (その場合は rails 3.x gem をアンインストールする必要はありません)、さらに良いことですが、それが不可能な場合は、rvm の gemsetsを参照してください。

古いアプリケーションを起動する必要があるときに私がすること:

  1. rvm use ree- アプリケーションがサーバーで Ruby Enterprise Edition を使用している場合、そうでない場合rvm use [ruby version here]は、バージョンによって異なります
  2. rvm gemset create [application name here]- このアプリケーションに固有の gemset を作成する
  3. rvm alias create [application name here] ree@[gemset name here]- このジェムセットにすぐに戻れるようにするため
  4. rvm use [alias name here]- アプリケーション ruby​​-gemset の組み合わせに切り替える
  5. アプリケーションに必要なすべての gem をインストールします (他の開発者に、どのバージョンを使用する必要があるか、どのようにインストールするかを尋ねます)

その後、このアプリケーションの開発に戻るたびに:

  1. rvm use [alias name here]
  2. ./script/server- アプリケーションを開始するには

このバージョンで開発する場合は、Rails 2.x のチュートリアルとドキュメントも探す必要があります。

于 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アプリのルートディレクトリにあるbinディレクトリを確認してください。削除しましたが、問題が発生していました。bin ディレクトリを作成し、少なくともこれらのファイルをコピーします。

バンドルレールレーキ

他の Rails プロジェクトから。

于 2014-10-10T17:47:00.053 に答える