質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.47%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

0回答

1124閲覧

Rails herokuでのデプロイ エラー(undefined method `[]' for nil:NilClass)

退会済みユーザー

退会済みユーザー

総合スコア0

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2021/09/06 20:59

編集2021/09/08 12:58

herokuでデプロイしたい

Ruby on Railsでアルバイトを募集できるWebアプリをつくっています。
試しにherokuでデプロイしてみようとも思い作業していたのですがうまくできません。
よろしければお力をお貸しください。

発生している問題・エラーメッセージ

Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used. Detected buildpacks: Ruby,Node.js 中略 Preparing app for Rails asset pipeline Running: rake assets:precompile rake aborted! NoMethodError: undefined method `[]' for nil:NilClass 中略 Precompiling assets failed. Push rejected, failed to compile Ruby app.

エラーメッセージ

remote: Bundle completed (145.94s) remote: Cleaning up the bundler cache. remote: Removing bundler (2.2.21) remote: -----> Installing node-v12.16.2-linux-x64 remote: -----> Installing yarn-v1.22.4 remote: -----> Detecting rake tasks remote: -----> Preparing app for Rails asset pipeline remote: Running: rake assets:precompile remote: rake aborted! remote: NoMethodError: undefined method `[]' for nil:NilClass remote: /tmp/build_d54fb60d/config/initializers/devise.rb:27:in `block in <main>' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/devise-4.8.0/lib/devise.rb:307:in `setup' remote: /tmp/build_d54fb60d/config/initializers/devise.rb:11:in `<main>' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:60:in `load' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:326:in `block in load' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:326:in `load' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/engine.rb:681:in `block in load_config_initializer' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/notifications.rb:205:in `instrument' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/engine.rb:680:in `load_config_initializer' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/engine.rb:634:in `block (2 levels) in <class:Engine>' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/engine.rb:633:in `each' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/engine.rb:633:in `block in <class:Engine>' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in `instance_exec' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:32:in `run' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:61:in `block in run_initializers' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:50:in `each' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:50:in `tsort_each_child' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/initializable.rb:60:in `run_initializers' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/application.rb:391:in `initialize!' remote: /tmp/build_d54fb60d/config/environment.rb:5:in `<main>' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `block in require' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:299:in `load_dependency' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/dependencies.rb:332:in `require' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/application.rb:367:in `require_environment!' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/railties-6.1.4.1/lib/rails/application.rb:533:in `block in run_tasks_blocks' remote: /tmp/build_d54fb60d/vendor/bundle/ruby/3.0.0/gems/sprockets-rails-3.2.2/lib/sprockets/rails/task.rb:61:in `block (2 levels) in define' remote: Tasks: TOP => environment remote: (See full trace by running task with --trace) remote: remote: ! remote: ! Precompiling assets failed. remote: ! remote: ! Push rejected, failed to compile Ruby app. remote: remote: ! Push failed remote: ! remote: ! ## Warning - The same version of this code has already been built: 5c943d94b57e7f07c6c3ab0484bf96167854683a remote: ! remote: ! We have detected that you have triggered a build from source code with version 5c943d94b57e7f07c6c3ab0484bf96167854683a remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch. remote: ! remote: ! If you are developing on a branch and deploying via git you must run: remote: ! remote: ! git push heroku <branchname>:main remote: ! remote: ! This article goes into details on the behavior: remote: ! https://devcenter.heroku.com/articles/duplicate-build-version remote: remote: Verifying deploy...

イメージ説明
イメージ説明

devise.rb

Devise.setup do |config| config.mailer_sender = Settings.gmail[:user_name] config.mailer_sender = '"Aiaru" <inf@aiaru.com>' require 'devise/orm/active_record' config.case_insensitive_keys = [:email] config.strip_whitespace_keys = [:email] config.skip_session_storage = [:http_auth] config.stretches = Rails.env.test? ? 1 : 12 config.reconfirmable = true config.expire_all_remember_me_on_sign_out = true config.password_length = 6..128 config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ config.reset_password_within = 6.hours config.scoped_views = true config.sign_out_via = :delete end

試したこと

下記のコードをconfig/application.rb」に記入しました
config.assets.initialize_on_precompile = false

下記のコードを実行しました
RAILS_ENV=development bin/rails assets:precompile
その結果
Everything's up-to-date. Nothing to do
となりました。

下記のコードを実行しました
RAILS_ENV=production bin/rails assets:precompile
そのところ、
rails aborted!
NameError: uninitialized constant Rack::MiniProfiler
Did you mean? MiniMime
となったのですが、これの言っている意味がよく分かりません。

よろしくお願いいたします

補足情報(FW/ツールのバージョンなど)

mac
ruby 3.0.2
awsのs3を使っています。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

winterboum

2021/09/06 23:23

ふたつ 1. NoMethodError: undefined method `[]' for nil:NilClass の前後にどこで発生したかの情報がありませんか? 2. Gemfileを載せてください
退会済みユーザー

退会済みユーザー

2021/09/07 05:39

winterboum様、コメントありがとうございます 編集しましたので、よろしくお願いいたします。
winterboum

2021/09/07 06:36

画像でなくtextで貼ってください。読みにくいし検索もできない
退会済みユーザー

退会済みユーザー

2021/09/07 07:00

winterboum様 すみません。承知しました。 修正しましたので、よろしくお願い致します。
winterboum

2021/09/07 08:51

読みやすくなりました。 これだ! というのが私には見つからなかったのですが、一点気になる所が remote: ! ## Warning - The same version of this code has already been built: 5c943d94b57e7f07c6c3ab0484bf96167854683a remote: ! remote: ! We have detected that you have triggered a build from source code with version 5c943d94b57e7f07c6c3ab0484bf96167854683a remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch. remote: ! この自覚というか、ありますか?
退会済みユーザー

退会済みユーザー

2021/09/07 09:19

winterboum様 明確にはわからないのですが、何度もデプロイ(git push heroku master)を試しているので重複しているということを言っているのかと考えていました。
winterboum

2021/09/07 12:28

branch は master しかない?
退会済みユーザー

退会済みユーザー

2021/09/07 19:35

winterboum様 はい。masterしかありません
winterboum

2021/09/07 22:41

config/initializers/devise.rb 見せてください
退会済みユーザー

退会済みユーザー

2021/09/08 12:59

winterboum様 ご返信遅れてしまい申し訳ありません。 devise.rbを載せましたので、よろしくお願い致します。 また、文字数制限のためGemfileを画像に変えさせていただきました。申し訳ありません。
MasaSakano

2021/09/09 11:12

エラーメッセージを載せていますが、何をした時にそのエラーが出たのかわかりません。 「試したこと」は、ローカル環境で行ったのでしょうか? 「試したこと」とheroku環境との関係(エラーメッセージとか)がよくわかりません。herokuとローカル環境とは異なります。異なる二つのことについて質問なさっているように見えます。NoMethodErrorとNameErrorとは、全然異なる環境や実行コマンドの結果として出てきた? それとも同じコマンド? その辺を明快に記述すれば質問が改善されると思いました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.47%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問