Webページで画像を表示するにはコンパイルする必要があります。
まずはシークレットキーを表示します。
コマンド
rails secret
シークレットキーが表示されるのでコピーします。
C:\WinRails\Gakushuu>rails secret d151e6c42c09f712157809236fd6676759adb2e3f35ddcb0d5b482ae5c687faf32cb8fd2cf312a03d2c1634a77072031f2c4a6702cd75a52aadf839c86c40068
「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: c865468c9c15435f18b204d66f1b55ad26ef210118eab8248d49b361dc8bc4fab5e3d0d50d6e21acf34ec7f000caf5297b15f8880931109e8ab01051fc95a0e6 test: secret_key_base: cf1ecc5a796bcefb14b6de47b2e8d34bce130a741604e18202ddc552eb2a44605a6e09f631c4164a77c72ae805844171e12e7ad6a93ac589bffcda47692c58d8 # Do not keep production secrets in the repository, # instead read values from the environment. production: secret_key_base: d151e6c42c09f712157809236fd6676759adb2e3f35ddcb0d5b482ae5c687faf32cb8fd2cf312a03d2c1634a77072031f2c4a6702cd75a52aadf839c86c40068 #secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
以下のコマンドを実行してコンパイルを行います。
コマンド
rails assets:precompile RAILS_ENV=production
バンドラーの改行コードを変更します。
これをしないとHEROKUデプロイ時にバンドラーのエラーがでます。
「bin\bundle」ファイルを開いて右下の「CRLF」をクリックして改行コードを選択します。
上部で改行コード選択ができるので「LF」を選択します。
上書き保存して「LF」に変更します。
Gitにコミットします。
ソース管理を選択します。
「+」をクリックして全ての変更をステージします。
コミットネームを入力します。
チェックマークをクリックしてコミットします。
下部にある同期ボタンをクリックしてGitと同期します。