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

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

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

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

Ruby

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

Git

Gitはオープンソースの分散バージョン管理システム(DVCS)です。

Heroku

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

Q&A

1回答

5576閲覧

Precompiling assets failed が治りません(Herokuデプロイ)[Railsチュートリアル11章]

Yui-Sato

総合スコア12

Ruby on Rails 5

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

Ruby

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

Git

Gitはオープンソースの分散バージョン管理システム(DVCS)です。

Heroku

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

1グッド

0クリップ

投稿2019/02/19 15:27

前提・実現したいこと

本番環境にデプロイしたい。

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

Rails Tutorialを学習している者です。
11章の終盤、アカウント有効化を実装したウェブサイトを本番環境にデプロイしようとしたところ以下のようなメッセージが出て、
一部デプロイできないことがわかったのですが、どうすればいいか分からず、見事にハマっています。NameErrorの部分が原因だと思うのですが、なかなか解決できない状況です。

エラーメッセージ

Ruby

1remote: ! 2remote: ! Precompiling assets failed. 3remote: ! 4remote:

該当のソースコード(ターミナル)

Ruby

1git push heroku #実行コマンド 2     :  #省略 3remote: 4remote: -----> Ruby app detected 5remote: -----> Compiling Ruby/Rails 6remote: -----> Using Ruby version: ruby-2.5.3 7remote: :    #省略 8remote: : 9remote: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.17.2). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. 10remote: The latest bundler is 2.0.1, but you are currently running 1.15.2. 11remote: To update, run `gem install bundler` 12remote: -----> Installing node-v10.14.1-linux-x64 13remote: -----> Detecting rake tasks 14remote: -----> Preparing app for Rails asset pipeline 15remote: Running: rake assets:precompile 16remote: rake aborted! 17remote: NameError: undefined local variable or method ` config' for #<SampleApp::Application:0x0000557bb768cd00> 18remote: /tmp/build_7a2ce75555da1d95e3c1edc54374905e/config/environments/production.rb:68:in `block in <top (required)>' 19remote: /tmp/build_7a2ce75555da1d95e3c1edc54374905e/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/railtie.rb:211:in `instance_eval' 20remote: /tmp/build_7a2ce75555da1d95e3c1edc54374905e/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/railtie.rb:211:in `configure' 21remote: /tmp/build_7a2ce75555da1d95e3c1edc54374905e/config/environments/production.rb:1:in `<top (required)>' 22remote: /tmp/build_7a2ce75555da1d95e3c1edc54374905e/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require' 23remote: /tmp/build_7a2ce75555da1d95e3c1edc54374905e/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require' 24remote: /tmp/build_7a2ce75555da1d95e3c1edc54374905e/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency' 25 : 26 : 27 : #字数制限のため1部省略 28                 29 30remote: Tasks: TOP => environment 31remote: (See full trace by running task with --trace) 32remote: 33remote: ! 34remote: ! Precompiling assets failed. 35remote: ! 36remote: ! Push rejected, failed to compile Ruby app. 37remote: 38remote: ! Push failed 39remote: Verifying deploy... 40remote: 41remote: ! Push rejected to 自分のクラウドIDE. 42remote: 43To https://自分のクラウドIDE.git 44 ! [remote rejected] master -> master (pre-receive hook declined) 45error: failed to push some refs to 'https://git.自分のクラウドIDE.git'

production.rb(config/environments)のソースコード↓

ソースコード Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true # Attempt to read encrypted secrets from `config/secrets.yml.enc`. # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or # `config/secrets.yml.key`. config.read_encrypted_secrets = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com' # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Mount Action Cable outside main process or domain # config.action_cable.mount_path = nil # config.action_cable.url = 'wss://example.com/cable' # config.action_cable.allowed_request_origins = [ 'http://example.com', /http://example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true config.force_ssl = true # Use the lowest log level to ensure availability of diagnostic information # when problems arise. config.log_level = :debug # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] # Use a different cache store in production. # config.cache_store = :mem_cache_store # Use a real queuing backend for Active Job (and separate queues per environment) # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "sample_app_#{Rails.env}" config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors.  config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :smtp host = '自分のクラウドIDE' config.action_mailer.default_url_options = { host: host } ActionMailer::Base.smtp_settings = { :address => 'smtp.sendgrid.net', :port => '587', :authentication => :plain, :user_name => ENV['SENDGRID_USERNAME'], :password => ENV['SENDGRID_PASSWORD'], :domain => 'heroku.com', :enable_starttls_auto => true } # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Use a different logger for distributed setups. # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false end

application.rbのソースコード(config/)↓

require_relative

1 2require 'rails/all' 3 4# Require the gems listed in Gemfile, including any gems 5# you've limited to :test, :development, or :production. 6Bundler.require(*Rails.groups) 7 8module SampleApp 9 class Application < Rails::Application 10 # Initialize configuration defaults for originally generated Rails version. 11 # Settings in config/environments/* take precedence over those specified here. 12 # Application configuration should go into files in config/initializers 13 # -- all .rb files in that directory are automatically loaded. 14 config.assets.initialize_on_precompile = false 15 16 # Include the authenticity token in remote forms. 17 config.action_view.embed_authenticity_token_in_remote_forms = true 18 end 19end 20コード

試したこと

他サイトで有力だった config.assets.initialize_on_precompile = false をapplication.rb(config/)に入れたりするも変化なし。

ここにより詳細な情報を記載してください。

退会済みユーザー👍を押しています

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

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

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

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

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

guest

回答1

0

NameError: undefined local variable or method ` config'

クリティカルなエラーはこちらですね。
congifの前に全角スペースが入っているようです。

config/enconfig/environments/production.rbvironments/production.rb に全角スペースがないか確認してみてください。

投稿2019/03/19 00:11

ykp_yk

総合スコア654

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

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

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

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

ただいまの回答率
85.49%

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

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

質問する

関連した質問