Ruby on Rails

dbに接続できない - could not connect to server

Dockerを使ってRails6の環境を作り、docker-compose upで起動すると、以下のようなエラーが表示されました。 PG::ConnectionBad: could not connect to server: No such file or directoryIs the server running locally and acceptingconnections on Unix d…

Dockerでコンテナ化したrailsアプリをproductionモードで起動する

Dockerでコンテナ化したrailsアプリをproductionモード(本番環境)で起動する方法をメモします。 productionモードとして起動するには以下のような設定項目があります。 production用docker-compose.ymlを用意DB設定ファイルの編集(config/database.yml)secre…

Rails - productionモードでAction Textがロードされない

タイトル通りの問題が起きて調べたのでメモします。 Action Textを導入したrailsアプリをproductionモードで実行したところ、Action Textを用いて実装した箇所がブラウザにロードされない事象が起きました。 解決策 以下のように、config/initializers/asset…

Rails - param is missing or the value is empty: エラー

param is missing or the value is empty: 以下のようなviewとコントローラ(Strong Parameters)を書いていたところ、POST時にparam is missing or the value is empty: article というエラーが発生しました。コードの趣旨としては、articleモデルの属性であ…

Rails - Media Queriesが効かない

問題 Rails on Railsでviewを書いている時に、以下のようにcssをレスポンシブ対応していたのですが、画面を480px以下にしてもスマホ向けのcssが適用されない現象が起きました。 header { color: white; } @media (max-width: 480px) { header { color: black…