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

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

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

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

Ruby on Rails

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

Q&A

解決済

2回答

459閲覧

Rails 5.1でherokuにデプロイできない

退会済みユーザー

退会済みユーザー

総合スコア0

Heroku

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

Ruby on Rails

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

0グッド

0クリップ

投稿2018/04/02 08:34

編集2018/04/02 08:51

前提・実現したいこと

Rails 5.1で作成したwebアプリをherokuにデプロイしたい。
Railsチュートリアルを参考に進めてきましたが、デプロイの段階でエラーが発生し、yarnやnodeをダウンロードしろと言われ実行。
その後も後述の試したことを実行し、デプロイを試し続けていると以下のエラーメッセージが発生。
おそらく原因は書いてある通りapplication.jsのNoMethodErrorだとは思うのですが、自身で書いたところに思い当たる場所はない。
全く見当違いなのかどうなのかもわからない状況です。
もし解決策がわかる方がいらっしゃいましたら教えていただきたいです。

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

エラーメッセージ ・ ・ ・ remote: -----> Detecting rake tasks remote: -----> Preparing app for Rails asset pipeline remote: Running: rake assets:precompile remote: yarn install v1.5.1 remote: remote: info No lockfile found. remote: remote: [1/5] Validating package.json... remote: remote: [2/5] Resolving packages... remote: remote: [3/5] Fetching packages... remote: remote: [4/5] Linking dependencies... remote: remote: [5/5] Building fresh packages... remote: remote: info Lockfile not saved, no dependencies. remote: remote: Done in 0.08s. remote: remote: I, [2018-04-02T07:54:42.087276 #1462] INFO -- : Writing /tmp/build_d143afa130a0f73d37ef2131d4688446/public/assets/application-c6dfdd4d1c5e54c6df669b033436b08bed94a7943fd9207542e7b5c64998d5d7.js remote: remote: I, [2018-04-02T07:54:42.088046 #1462] INFO -- : Writing /tmp/build_d143afa130a0f73d37ef2131d4688446/public/assets/application-c6dfdd4d1c5e54c6df669b033436b08bed94a7943fd9207542e7b5c64998d5d7.js.gz remote: remote: rake aborted! remote: remote: NoMethodError: undefined method `[]' for nil:NilClass remote: remote: /tmp/build_f93f2039b4d4fa17656aa8ba68ac7fe9/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/sass_processor.rb:278:in `sprockets_context' remote: remote: /tmp/build_f93f2039b4d4fa17656aa8ba68ac7fe9/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/sass_processor.rb:124:in `asset_path' ・ ・#文字制限のため省略 ・ remote: remote: /tmp/build_f93f2039b4d4fa17656aa8ba68ac7fe9/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:185:in `compile' remote: remote: /tmp/build_f93f2039b4d4fa17656aa8ba68ac7fe9/vendor/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define' remote: remote: /tmp/build_f93f2039b4d4fa17656aa8ba68ac7fe9/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:147:in `with_logger' remote: remote: /tmp/build_f93f2039b4d4fa17656aa8ba68ac7fe9/vendor/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define' remote: remote: /tmp/build_f93f2039b4d4fa17656aa8ba68ac7fe9/vendor/bundle/ruby/2.4.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>' remote: remote: Tasks: TOP => assets:precompile remote: 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: Verifying deploy... remote: remote: ! Push rejected to warm-earth-28275. remote: To https://git.heroku.com/warm-earth-28275.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/warm-earth-28275.git'
#application.js // This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's // vendor/assets/javascripts directory can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. JavaScript code in this file should be added after the last require_* statement. // // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // //= require jquery //= require rails-ujs //= require turbolinks //= require_tree . $(document).ready(function(){ $(window).load(function(){ window.setTimeout("$('#alertfadeout').fadeOut()", 2000); }); });

試したこと

yarnのダウンロード+インストール
node.jsのダウンロード+インストール

#コマンドプロンプト $heroku buildpacks:add --index 1 heroku/nodejs $heroku buildpacks:add --index 2 heroku/ruby

の実行

#package.json "engines": { "yarn": "バージョン", "node": "バージョン" }

の追加

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

#gemfile source 'https://rubygems.org' ruby '2.4.3' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.5' # Use Puma as the app server gem 'puma', '~> 3.7' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development group :development, :test do # Use sqlite3 as the database for Active Record gem 'sqlite3' # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] # Adds support for Capybara system testing and selenium driver gem 'capybara', '~> 2.13' gem 'selenium-webdriver' end group :development do # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. gem 'web-console', '>= 3.3.0' end group :production do gem 'pg' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'coffee-script-source', '1.8.0' gem 'bootstrap-sass', '3.2.0.0' gem "jquery-rails"

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

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

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

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

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

maisumakun

2018/04/02 08:38

NoMethodErrorの「後の」行のほうに発生場所などが書かれていますので、そちらの情報もお願いします。
退会済みユーザー

退会済みユーザー

2018/04/02 08:55

追記しました。同じ様な内容がずらっとある場所は文字制限の関係で省略しました。必要であれば言ってください。
guest

回答2

0

ベストアンサー

こちらの質問を参考に自己解決しました。
application.cssをapplication.css.scssにリネームするとデプロイに成功しました。
回答や反応をしてくださった方に感謝します。

投稿2018/04/02 12:06

退会済みユーザー

退会済みユーザー

総合スコア0

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

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

0

一つずつコメントアウトをして問題の切り分けを行ってみてはいかがでしょうか?

投稿2018/04/02 08:37

kenny_sayama

総合スコア1036

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

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

退会済みユーザー

退会済みユーザー

2018/04/02 08:54

回答ありがとうございます。 application.jsの「//」の行を1行ずつコメントアウトして試していくということでしょうか? やってみます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問