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

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

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

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

Ruby on Rails

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

Q&A

解決済

1回答

2546閲覧

railsをHerokuにデプロイできない

madao

総合スコア24

Heroku

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

Ruby on Rails

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

0グッド

0クリップ

投稿2016/11/20 08:42

###前提・実現したいこと
ここに質問したいことを詳細に書いてください
(例)PHP(CakePHP)で●●なシステムを作っています。
■■な機能を実装中に以下のエラーメッセージが発生しました。
初めてrailsでアプリを作っています。
そこで公開しようと、Herokuのサーバーを使おうと考えました。
しかし、デプロイしようとした時に以下のエラーメッセージが発生しました。

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

エラーメッセージ bundle exec rake -P を実行した時 NameError: undefined local variable or method `config' for main:Object application.rb:5:in `<top (required)>' Rakefile:4:in `require_relative' Rakefile:4:in `<top (required)>' .rbenv/versions/2.3.1/bin/bundle:23:in `load' .rbenv/versions/2.3.1/bin/bundle:23:in `<main>' (See full trace by running task with --trace)

###該当のソースコード

applecation.rb require_relative 'boot' require 'rails/all' config.time_zone = 'tokyo' config.active_record.default_timezone = :local config.force_ssl = true # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module OTOSHIMONO class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. end end Rakefile # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require_relative 'config/application' Rails.application.load_tasks

###試したこと
自分なりにググり修正したんですが全く改善されませんでした。
お力添え願いたいです。

###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報

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

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

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

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

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

guest

回答1

0

ベストアンサー

Ruby

1config.time_zone = 'tokyo' 2config.active_record.default_timezone = :local 3 4config.force_ssl = true

Ruby

1module OTOSHIMONO 2 class Application < Rails::Application

の下に移動してみて下さい。

ちなみにこの状態で手元では動くんですか? bin/rails s するとエラーになるのでは…???

投稿2016/11/21 10:57

退会済みユーザー

退会済みユーザー

総合スコア0

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

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

madao

2016/11/22 01:52

BSDmadさんありがとうございます。今までの状況は脱することができましたが、ご指摘の通り rails s するとエラーになってしまいました。 さらにデプロイしようとしても新たなエラーが発生しました。以下がrake -Pした時の文です rake about environment rake app:template environment rake app:templates:copy rake app:update update:configs update:bin rake app:update:bin rake app:update:configs rake assets:clean environment rake assets:clobber environment rake assets:environment rake assets:precompile environment rake cache_digests:dependencies environment rake cache_digests:nested_dependencies environment rake db:_dump rake db:abort_if_pending_migrations environment load_config rake db:charset environment load_config rake db:check_protected_environments environment load_config rake db:collation environment load_config rake db:create load_config rake db:create:all load_config rake db:drop load_config check_protected_environments rake db:drop:_unsafe load_config rake db:drop:all load_config check_protected_environments rake db:environment:set environment load_config rake db:fixtures:identify environment load_config rake db:fixtures:load environment load_config rake db:forward environment load_config rake db:load_config rake db:migrate environment load_config rake db:migrate:down environment load_config rake db:migrate:redo environment load_config rake db:migrate:reset db:drop db:create db:migrate rake db:migrate:status environment load_config rake db:migrate:up environment load_config rake db:purge load_config check_protected_environments rake db:purge:all load_config check_protected_environments rake db:reset db:drop db:setup rake db:rollback environment load_config rake db:schema:cache:clear environment load_config rake db:schema:cache:dump environment load_config rake db:schema:dump environment load_config rake db:schema:load environment load_config check_protected_environments rake db:schema:load_if_ruby db:create environment rake db:seed rake db:setup db:schema:load_if_ruby db:structure:load_if_sql seed rake db:structure:dump environment load_config rake db:structure:load environment load_config check_protected_environments rake db:structure:load_if_sql db:create environment rake db:test:clone db:test:deprecated environment rake db:test:clone_schema db:test:deprecated db:schema:dump db:test:load_schema rake db:test:clone_structure db:test:deprecated db:structure:dump db:test:load_structure rake db:test:deprecated rake db:test:load db:test:purge rake db:test:load_schema db:test:purge rake db:test:load_structure db:test:purge rake db:test:prepare environment load_config rake db:test:purge environment load_config check_protected_environments rake db:version environment load_config rake default test rake dev:cache rake environment rake initializers environment rake log:clear rake middleware environment rake notes rake notes:custom rake notes:fixme rake notes:optimize rake notes:todo rake rails:template rake rails:templates:copy rake rails:update rake rails:update:bin rake rails:update:configs rake railties:install:migrations db:load_config rake restart rake routes environment rake secret rake stats rake test rake test:controllers test:prepare rake test:db db:test:prepare test rake test:functionals test:prepare rake test:generators test:prepare rake test:helpers test:prepare rake test:integration test:prepare rake test:jobs test:prepare rake test:mailers test:prepare rake test:models test:prepare rake test:prepare rake test:run test rake test:units test:prepare rake time:zones rake time:zones:all rake time:zones:local rake time:zones:us rake tmp rake tmp/cache rake tmp/cache/assets rake tmp/pids rake tmp/sockets rake tmp:cache:clear rake tmp:clear tmp:cache:clear tmp:sockets:clear rake tmp:create tmp/cache tmp/sockets tmp/pids tmp/cache/assets rake tmp:pids:clear rake tmp:sockets:clear
退会済みユーザー

退会済みユーザー

2016/11/22 06:45

まずは手元で動くようにし、Heroku への deploy 云々はその後にしましょう。 手元で動かないとのことですが、エラーは?
madao

2016/11/22 14:13

了解です。元々は動いてたんですけどHerokuにデプロイしようといじってたら動かなくなってしまいました笑 以下エラーです HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails.> 2016-11-22 23:11:22 +0900: ENV: {"rack.version"=>[1, 3], "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>true, "rack.multiprocess"=>false, "rack.run_once"=>false, "SCRIPT_NAME"=>"", "QUERY_STRING"=>"", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"puma 3.6.1 Sleepy Sunday Serenity", "GATEWAY_INTERFACE"=>"CGI/1.2"} ---
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問