Webページで画像を表示するにはコンパイルする必要があります。
まずはシークレットキーを表示します。
コマンド
rails secret
シークレットキーが表示されるのでコピーします。
C:\WinRails\Minpaku>rails secret b670a9c37794185ee89dc7a319db8ba11bb0cc4e84aee5bbb1c5d7866fe0b7679ffe36f89991234c6028cfae5d5c6cfe5de9981a73d935e166758ec30ff8b0b0
「config\secrets.yml」の「production」部分にコピーしたシークレットキーを貼り付けます。(22行目)
記述変更 config\secrets.yml
# Be sure to restart your server when you modify this file. # Your secret key is used for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. # You can use `rails secret` to generate a secure secret key. # Make sure the secrets in this file are kept private # if you're sharing your code publicly. development: secret_key_base: 2139b49ebaebb920b09186c74b0729201769c50e1529507f3e349c3542b5697832a13b012e7be211a54bdc7ab22eb2e97fc2ab36e92b81b21857133e321ee8fc test: secret_key_base: 68e6f37c87e6739345af5d97a1d90f55f7f4ddf10388ee47b568045dc732ce76fbb481262aff938cbaf3011d50079367fd77f8b67964874f2253ab660131dcc5 # Do not keep production secrets in the repository, # instead read values from the environment. production: secret_key_base: b670a9c37794185ee89dc7a319db8ba11bb0cc4e84aee5bbb1c5d7866fe0b7679ffe36f89991234c6028cfae5d5c6cfe5de9981a73d935e166758ec30ff8b0b0 # secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
以下のコマンドを実行してコンパイルを行います。
コマンド
rails assets:precompile RAILS_ENV=production
バンドラーの改行コードを変更します。
これをしないとHEROKUデプロイ時にバンドラーのエラーがでます。
「bin\bundle」ファイルを開いて右下の「CRLF」をクリックして改行コードを選択します。
上部で改行コード選択ができるので「LF」を選択します。
上書き保存して「LF」に変更します。
Gitにコミットします。
ソース管理を選択します。
「+」をクリックして全ての変更をステージします。
コミットネームを入力します。
チェックマークをクリックしてコミットします。
下部にある同期ボタンをクリックしてGitと同期します。