LoginSignup
4
1

More than 5 years have passed since last update.

RailsでStatic Fileの配信をする

Posted at

LocalでPumaをproductionモードで動作させたときに少しハマったのでメモ書きです。

Rails5から利用可能なWebpackerでJavascriptファイルを1つにまとめて配信しようと思いpumaを起動し、Webにアクセスしてみると
ActionController::RoutingError (No route matches [GET] "/packs/application-xxxxxxxxxx.js")
とエラーが出てた。

いろいろ悩んでたら下記の記事を発見。
Railsに静的ファイルの配信をお願いする

静的ファイル(html,js,css等)を配信するのはそもそもWebサーバのお仕事なので、
APサーバがやることではないのよね。

config/environments/production.rbconfig.server_static_files = trueに書き換えてpumaを起動したらうまく配信してくれた。

よし、nginx用意しよう。。。

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1