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

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

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

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

Heroku

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

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

phpMyAdmin

phpMyAdminはオープンソースで、PHPで書かれたウェブベースのMySQL管理ツールのことです。

Ruby on Rails

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

Q&A

解決済

2回答

392閲覧

HerokuにClearDBアドオンをしたらDBのテーブルが足りない。

k.chisato

総合スコア18

Ruby

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

Heroku

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

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

phpMyAdmin

phpMyAdminはオープンソースで、PHPで書かれたウェブベースのMySQL管理ツールのことです。

Ruby on Rails

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

0グッド

0クリップ

投稿2019/03/25 10:09

編集2019/03/27 06:49

前提

ユーザー登録を必要とするSNS的なアプリを開発中です。
いよいよα版を公開!と思ったら最後の最後につまづいています・・・

https://life-stamp-rally.herokuapp.com/users

Heroku上にアプリケーションを作成し、ブラウザにトップページを表示するところまでは出来ています。
しかしログインページや新規会員登録に遷移すると下記エラーが発生。

イメージ説明

HeidiSQLを使用してデータベースに接続をしてみると、
本来あるはずのUsersテーブルがありませんでした!!

イメージ説明
※開発環境

イメージ説明
※HeidiSQL(herokuにデプロイしたアプリのデータベース)

Herokuのバージョンは18、
Rubyのバージョンは2.5.1、
railsのバージョンは5.2.2.1、
DBは開発環境でMySQL(phpmyadmin)を使っています。

アドオンは普通に問題無く出来ている様に見えます・・・

ec2-user:~/environment/ver0.3 (master) $ heroku addons:info cleardb === cleardb-crystalline-67196 Attachments: life-stamp-rally::CLEARDB_DATABASE Installed at: Tue Mar 26 2019 02:24:55 GMT+0000 (Coordinated Universal Time) Owning app: life-stamp-rally Plan: cleardb:ignite Price: free State: created

以下schema.rb

ActiveRecord::Schema.define(version: 2019_03_19_064642) do create_table "active_storage_attachments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false t.bigint "record_id", null: false t.bigint "blob_id", null: false t.datetime "created_at", null: false t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true end create_table "active_storage_blobs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.string "key", null: false t.string "filename", null: false t.string "content_type" t.text "metadata" t.bigint "byte_size", null: false t.string "checksum", null: false t.datetime "created_at", null: false t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true end create_table "countries", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.string "country" t.string "capital" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "continent" t.float "latitude", limit: 53 t.float "longitude", limit: 53 end create_table "remove_latitude_from_countries", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.integer "latitude" t.integer "longitude" t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "stamps", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.integer "user_id" t.text "title" t.text "description" t.datetime "shooted_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "country_id" end create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "family_name" t.string "first_name" t.string "family_name_kana" t.string "first_name_kana" t.index ["email"], name: "index_users_on_email", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" end

以下database.yml

default: &default adapter: mysql2 encoding: utf8 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: root password: socket: /var/lib/mysql/mysql.sock development: <<: *default database: ver0_2_development test: <<: *default database: ver0_2_test production: <<: *default database: ver0_2_production username: ver0_2 password: <%= ENV['VER0_2_DATABASE_PASSWORD'] %>

Gemfile

1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '2.5.1' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7gem 'rails', '~> 5.2.2', '>= 5.2.2.1' 8# Use mysql as the database for Active Record 9gem 'mysql2', '0.5.2' 10# Use Puma as the app server 11gem 'puma', '~> 3.11' 12# Use SCSS for stylesheets 13gem 'sass-rails', '~> 5.0.7' 14# Use Uglifier as compressor for JavaScript assets 15gem 'uglifier', '>= 1.3.0' 16# See https://github.com/rails/execjs#readme for more supported runtimes 17# gem 'mini_racer', platforms: :ruby 18 19# Use CoffeeScript for .coffee assets and views 20gem 'coffee-rails', '~> 4.2' 21# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 22gem 'turbolinks', '~> 5' 23# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 24gem 'jbuilder', '~> 2.5' 25# Use Redis adapter to run Action Cable in production 26# gem 'redis', '~> 4.0' 27# Use ActiveModel has_secure_password 28# gem 'bcrypt', '~> 3.1.7' 29 30# Use ActiveStorage variant 31# gem 'mini_magick', '~> 4.8' 32 33# Use Capistrano for deployment 34# gem 'capistrano-rails', group: :development 35 36# Reduces boot times through caching; required in config/boot.rb 37gem 'bootsnap', '>= 1.1.0', require: false 38 39group :development, :test do 40 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 41 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 42end 43 44group :development do 45 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 46 gem 'web-console', '>= 3.3.0' 47 gem 'listen', '>= 3.0.5', '< 3.2' 48 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 49 gem 'spring' 50 gem 'spring-watcher-listen', '~> 2.0.0' 51end 52 53group :test do 54 # Adds support for Capybara system testing and selenium driver 55 gem 'capybara', '>= 2.15' 56 gem 'selenium-webdriver' 57 # Easy installation and use of chromedriver to run system tests with Chrome 58 gem 'chromedriver-helper' 59end 60 61# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 62gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 63 64# アマゾンS3を追加 65gem 'aws-sdk-s3', require: false 66 67# 基本項目 68gem 'pry-rails' 69gem 'compass-rails', '3.1.0' 70gem 'sprockets', '3.7.2' 71gem 'hirb' 72gem 'hirb-unicode' 73 74# jQuery 75gem "jquery-rails" 76 77# ログイン 78gem 'devise' 79 80group :production do 81 gem 'rails_12factor' 82end

どなたかアドバイスを頂けると幸いです・・・

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

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

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

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

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

guest

回答2

0

自己解決

migrationファイルが一部欠損していたのが原因でした!
ですので一度開発環境でテーブル、migrationファイルを全て削除して綺麗に再生をしたところ上手く行きました。

(しょうも無くてすみません・・・)

投稿2019/04/02 05:02

k.chisato

総合スコア18

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

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

0

まずは、

heroku logs

でRailsアプリケーションのログを参照してみると良いと思います。

また、herokuは基本的にPostgreSQLですが、SQLは一部を除いて正常に動作すると思うので、Gemfileとconfig/database.ymlに必要な情報を記述してデプロイするのも一つの手かなと思いました。

投稿2019/03/26 11:54

bamboo-nova

総合スコア1408

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

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

k.chisato

2019/03/27 06:32 編集

ありがとうございます。 Heroku logsを試したところ、下記が表示されました。 --- 2019-03-26T08:15:34.988783+00:00 heroku[router]: at=info method=GET path="/users/sign_in" host=life-stamp-rally.herokuapp.com request_id=5d643fc3-f8ce-41ea-89b3-d883356c0ace fwd="52.71.155.178" dyno=web.1 connect=1ms service=89ms status=500 bytes=1827 protocol=https 2019-03-26T08:49:22.033723+00:00 heroku[web.1]: Idling 2019-03-26T08:49:22.062499+00:00 heroku[web.1]: State changed from up to down 2019-03-26T08:49:22.990471+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish 2019-03-26T08:49:22.992071+00:00 app[web.1]: === puma shutdown: 2019-03-26 08:49:22 +0000 === 2019-03-26T08:49:22.992103+00:00 app[web.1]: - Goodbye! 2019-03-26T08:49:22.992255+00:00 app[web.1]: Exiting 2019-03-26T08:49:22.976351+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2019-03-26T08:49:23.088899+00:00 heroku[web.1]: Process exited with status 143 2019-03-27T06:19:02.626278+00:00 heroku[web.1]: State changed from down to starting 2019-03-27T06:19:09.096026+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 3378 -e production` --- これはつまりHerokuを下記に従ってPumaサーバーを利用する変更をしなければならないということなのでしょうか・・・・? https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server >Gemfileとconfig/database.ymlに必要な情報を記述して →すみません、、、必要な情報とは具体的に何を指しておりますでしょうか?  例で構わないのでご教授頂けると嬉しいです・・・
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.47%

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

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

質問する

関連した質問