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

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

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

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

Heroku

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

PostgreSQL

PostgreSQLはオープンソースのオブジェクトリレーショナルデータベース管理システムです。 Oracle Databaseで使われるPL/SQLを参考に実装されたビルトイン言語で、Windows、 Mac、Linux、UNIX、MSなどいくつものプラットフォームに対応しています。

Q&A

1回答

912閲覧

rails herokuにデプロイできるが、DBの中身が空でログイン機能が実装できない

furufurufufufu

総合スコア16

Ruby on Rails 5

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

Heroku

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

PostgreSQL

PostgreSQLはオープンソースのオブジェクトリレーショナルデータベース管理システムです。 Oracle Databaseで使われるPL/SQLを参考に実装されたビルトイン言語で、Windows、 Mac、Linux、UNIX、MSなどいくつものプラットフォームに対応しています。

0グッド

0クリップ

投稿2020/08/10 04:03

自作している簡単なrailsアプリなのですが、ローカルでは問題ないのですが、herokuに上げると機能が実装されていないという問題が発生いたしました。

dbは開発環境からpostgresqlを使っています。

zsh

1git push heroku 2heroku run rake db:migrate

コマンドでデプロイ出来ましたが、ログイン機能を試すと、Eメールまたはパスワードが違いますとエラーが表示されます。
イメージ説明
ローカルでは問題なく実装されていました。
heroku/dataclipsで確認しますと、カラムは作成されたのですが、データが入っていないようなのです。
イメージ説明
イメージ説明
config/database.yml

# PostgreSQL. Versions 9.1 and up are supported. # # default: &default adapter: postgresql encoding: unicode # For details on connection pooling, see Rails configuration guide # http://guides.rubyonrails.org/configuring.html#database-pooling pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> development: <<: *default database: railsPosts_development test: <<: *default database: railsPosts_test production: <<: *default url: <%= ENV['DATABASE_URL'] %>

Gemfile

1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '2.6.5' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7gem 'rails', '~> 5.2.4', '>= 5.2.4.2' 8# Use postgresql as the database for Active Record 9gem 'pg', '>= 0.18', '< 2.0' 10# Use Puma as the app server 11gem 'puma', '~> 3.11' 12# Use SCSS for stylesheets 13gem 'sass-rails', '~> 5.0' 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 39# ログイン機能 40gem 'devise' 41 42# 日本語化 43gem 'rails-i18n', '~> 5.1' 44gem 'devise-i18n' 45gem 'i18n_generators' 46 47# Bootstrap 48gem 'bootstrap', '~> 4.4.1' 49gem 'jquery-rails' 50gem 'devise-bootstrap-views' 51 52gem "refile", require: "refile/rails", github: 'manfe/refile' 53gem "refile-mini_magick" 54 55group :development, :test do 56 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 57 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 58end 59 60group :development do 61 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 62 gem 'web-console', '>= 3.3.0' 63 gem 'listen', '>= 3.0.5', '< 3.2' 64 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 65 gem 'spring' 66 gem 'spring-watcher-listen', '~> 2.0.0' 67end 68 69group :test do 70 # Adds support for Capybara system testing and selenium driver 71 gem 'capybara', '>= 2.15' 72 gem 'selenium-webdriver' 73 # Easy installation and use of chromedriver to run system tests with Chrome 74 gem 'chromedriver-helper' 75end 76 77# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 78gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 79

production廻りは何も入れていないです。
ログイン機能はdeviseを使っています。

何故、ローカルのデータが本番環境に反映されないのでしょうか?

よろしくご教授の程、お願いいたします。

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

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

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

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

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

guest

回答1

0

本番サーバーにデプロイしても、開発環境で入力したデータは自動では反映されないので、インポートする必要があります。

https://devcenter.heroku.com/articles/heroku-postgres-import-export

https://qiita.com/shosho/items/5ebabf11efb1f3b604f7#%E3%82%A4%E3%83%B3%E3%83%9D%E3%83%BC%E3%83%88

投稿2020/08/10 04:30

no1knows

総合スコア3365

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問