Thinh Huynh
Thinh Huynh

Reputation: 81

Rails 5 api enable public folder browsable

I created rails api with Rails 5.0.0.rc1 and Ruby 2.3.0 I need to make "public" folder under application path is browsable

I added the below line into config/application.rb file

config.public_file_server.enabled = true

But my api could not browse public folder at link

http://localhost:3000/public/404.html

or http://localhost:3000/public

How can I do that Thanks

Upvotes: 0

Views: 2089

Answers (1)

victor sosa
victor sosa

Reputation: 899

On Nginx you need to set you location on autoindex to see the files in the directory using you browser.

youNginx.conf

location / {
  autoindex on;
}

config.public_file_server.enabled configures Rails to serve static files from the public directory. This option defaults to true, but in the production environment it is set to false because the server software (e.g. NGINX or Apache) used to run the application should serve static files instead. If you are running or testing your app in production mode using WEBrick (it is not recommended to use WEBrick in production) set the option to true. Otherwise, you won't be able to use page caching and request for files that exist under the public directory.

Upvotes: 0

Related Questions