ruby-on-rails-BUG

7019 ワード

Ruby on Rails errors:
(新米期)
rails自動化導入チュートリアル
Q 1:rvmが使えない
$ rvm use 1.9.3 --default

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example. 

次の操作を行います.
 source ~/.rvm/scripts/rvm

または、
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >>~/.bashrc
source ~/.bashrc

Q2: bundle install httpError
run  bundle install
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching source index from https://rubygems.org/

Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/
Retrying fetcher due to error (3/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org/
Retrying fetcher due to error (4/4): Bundler::HTTPError Could not fetch specs from https://rubygems.org

railsプロジェクトではGemfileとBundleを使用する必要があります.BundlerのGemソースコードでコマンドをミラーできます.
bundle config mirror.https://rubygems.org https://gems.ruby-china.org
Gemfileのソースを変更する必要はありません
```
参考リンク:ruby-chinaミラーステーションは稲妻のように速い!
Q 3:生産鍵rails 4 rails 5が異なる
ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit`

生産鍵の追加が必要
rails 4では、この鍵はrake secret RAILS_ENV=productionによって作成され、サーバ側に置かれた/home/xxx/your_web_app/shared/config/secrets.ymlではrails 5ではmasterに変更されました.key、ローカル/home/xxx/your_で使用する必要がありますweb_app/config/deploy.rbの:link_file手動で「config/master.key’
次のようになります.
# Default value for :linked_files is []                                          
append :linked_files, "config/database.yml", "config/master.key"     

Q4: rake aborted!
$ sudo rake secret --trace
rake aborted!
LoadError: cannot load such file -- bundler/setup

これはroot権限で実行する権限を付与しようとします
Beginning in Rails 4, Rails ships with a rails binstub at ./bin/rails that should be used instead of the Bundler-generated rails binstub.
Q5: The page you were looking for doesn't exist.
The page you were looking for doesn't exist.

You may have mistyped the address or the page may have moved.

ローカルテストは可能ですが、リモートサーバはできません.ルーティングに問題があることを確認し、リモート・ウェアハウスのコードを処理します(サーバ上ではリモート・ウェアハウスからコードを引き出しているはずです)
Q 6:ドロップダウンメニューはドロップダウンできません(bootstrapを使用)
ドロップダウンメニューはドロップダウンできません(bootstrapを使用)
この機能はjsのサポートが必要なので、/app/assert/javascript/アプリケーションに必要なjsライブラリを含める必要があります.jsに追加
//= require jquery

Q7:.... ? ..... : .....
syntax error, unexpected ';' : expecting keyword_end ...cost?BCrypt::Engine::MIN_COST : BCrypt::Engine.cost

これは...です.の式は、意外にも発見されなかったので、中間の疑問符は前の判断条件とスペースで区切らなければならない.
Q 8:stmpサービスをオープンする25ポート
F, [2018-09-06T20:33:15.955037 #21413] FATAL -- : [bdf765fc-3c26-4d8f-87be-c5357887f443] ActionView::Template::Error (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):
F, [2018-09-06T20:33:15.955131 #21413] FATAL -- : [bdf765fc-3c26-4d8f-87be-c5357887f443]     3: 

[bdf765fc-3c26-4d8f-87be-c5357887f443] 4: Welcome to the Sample App! Click on the link below to activate your account: [bdf765fc-3c26-4d8f-87be-c5357887f443] 5:

[bdf765fc-3c26-4d8f-87be-c5357887f443] 6: F, [2018-09-06T20:33:15.955158 #21413] FATAL -- : [bdf765fc-3c26-4d8f-87be-c5357887f443] F, [2018-09-06T20:33:15.955180 #21413] FATAL -- : [bdf765fc-3c26-4d8f-87be-c5357887f443] app/views/user_mailer/account_activation.html.erb:6:in `_app_views_user_mailer_account_activation_html_erb__374929091__625207508' [bdf765fc-3c26-4d8f-87be-c5357887f443] app/mailers/user_mailer.rb:11:in `account_activation' [bdf765fc-3c26-4d8f-87be-c5357887f443] app/models/user.rb:48:in `send_activation_email' [bdf765fc-3c26-4d8f-87be-c5357887f443] app/controllers/users_controller.rb:18:in `create'

まず私が見たチュートリアルはメールサーバーのホストhostを構成していません
しかし、構成が完了すると、イントラネット接続がタイムアウトするという問題が発生し、
I, [2018-10-07T23:58:53.103195 #26716]  INFO -- : [084c0592-31a4-492c-8686-9cac1b6d2ead] Completed 500 Internal Server Error in 30173ms (ActiveRecord: 7.9ms)
F, [2018-10-07T23:58:53.104096 #26716] FATAL -- : [084c0592-31a4-492c-8686-9cac1b6d2ead]
F, [2018-10-07T23:58:53.104154 #26716] FATAL -- : [084c0592-31a4-492c-8686-9cac1b6d2ead] Net::OpenTimeout (execution expired):
F, [2018-10-07T23:58:53.104187 #26716] FATAL -- : [084c0592-31a4-492c-8686-9cac1b6d2ead]
F, [2018-10-07T23:58:53.104220 #26716] FATAL -- : [084c0592-31a4-492c-8686-9cac1b6d2ead] app/models/user.rb:48:in `send_activation_email'
[084c0592-31a4-492c-8686-9cac1b6d2ead] app/controllers/users_controller.rb:18:in `create'

その結果、テンセント雲はstmpサービスの25ポートを閉鎖したことが分かった.so.工単申請解禁後、アクティブなメールボックスを正しく送信できます.
Q 7:サーバ側運用次元
サーバ側でmodelオブジェクトのプロパティを削除する方法
currentフォルダの下でrails console produtionを実行してこそ、本番環境のデータ情報に正常にアクセスできます.
モデルのファイルmodel/は現在のプロジェクトフォルダにファイルがないため、railsが実行できてもモデルオブジェクトが見つかりません.
irb(main):001:0> User.first
Traceback (most recent call last):
        1: from (irb):1
NameError (uninitialized constant User)

また、ローカルで使用するmysqlとリモートで使用するmysqlのパスワードが異なる場合はdatabase.ymlの配置も違います
            reset_at   ,          

古いタイムスタンプの移行に注意するには、移行が実行された後にdb:migrateを再使用しても効果はありません.db:rollback以降に効果がない限り、データベースを新しい削除するには、新しい移行ドキュメントdを作成する必要があります.
地元のテストはとても重要です
だから、ローカルブランチをむやみにサーバーに提出して配置しないでください.間違えて、面倒になります.
Q 9:科学計算環境
そうだ科学的なコンピューティング環境でrails仮想環境を実行しないで
実はanacondaで、LoadErrorをトリガーします
Q 10:ファームウェアのテスト
テストに失敗したファームウェアエラーnilを表示
解決方法:test/fixtures/xxx.ymlに必要なテストファームウェアを追加
'nil' is not an ActiveModel-compatible object. It must implement :to_partial_path.

viewの変数はnilなのでインタフェースをレンダリングできません
解決:対応するcontrollerでこの変数が定義されているかどうかを確認します.
Q 11:Gemfileはローカルのパッケージバージョンとは異なります
/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:313:in `check_for_activated_spec!': You have already activated i18n 1.1.1, but your Gemfile requires i18n 1.1.0. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)

これは、現在アクティブ化されているパッケージとGemfileでは要求が異なり、Gemfileを変更したりbundle updateを実行してパッケージを再構成したりすることができます.