1

Rails 4.2config/application.rbは、既存のアプリケーションで再生成する単一のコマンドを提供しますか?

私が尋ねる理由は、Rails アプリがオプションrails newなしで -ed であると想像するためです。--skip-test-unit

その後、かなり後になって、このアプリは RSpec に切り替えられました。オプションが最初に に提供されたかのように、どのconfig/application.rbように再生成できますか?--skip-test-unitrails new ...

これが効果的に行うことは、ファイルrequireの上部にあるステートメントを次のように変更することだけです。config/application.rb

require 'rails/all'

に:

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
4

1 に答える 1

4

既存のものを削除し、プロジェクト ルートのconfig/application.rbのディレクトリで、必要なオプション (アプリケーション ディレクトリ名、オプション、および既存のファイルの作成をスキップするオプションを含む) を指定し実行します。rails new ...--skip-test-unit--skiprails new ...

# Inside your-rails-app/ directory:

# 1. Remove config/application.rb
rm config/application.rb

# 2. Move up one directory
cd ..

# 3. Regenerate rails application with the --skip
#    option, using the name of your-rails-app. The
#    --skip option will not generate files that
#    already exist.
#     
#    This assumes you have rails installed as a global
#    gem, of the version given in the command (version
#    x.y.z in this case, replace with the version of Rails
#    your app uses, e.g. 4.2.88):
rails _x.y.z_ new your-rails-app --skip --skip-test-unit

# 4. Run git status to see if any files were unexpectedly added
#    (for example the README.rdoc file will be created
#    if it did not exist).
git status

# 5. Clean up and commit the changes you want.

以上です!

于 2015-05-21T16:51:46.067 に答える