Matt
Matt

Reputation: 22921

Why is stylesheets and scripts separate from app in rails directory structure

I never understood why the stylesheets and scripts are outside the /app folder in ruby on rails. Is there benefits of housing them in the /public folder away from the /app?

Thank! Matt

Upvotes: 2

Views: 73

Answers (2)

Joshua Partogi
Joshua Partogi

Reputation: 16425

In production environment, /app is served by Ruby appserver, i.e mongrel, thin, unicorn, etc, while /public is served by a webserver that is better in serving static content, i.e nginx. Sometimes you would also want to decouple /public to be served by a CDN, i.e Amazon S3. Decoupling this two directory provides better deployment arrangement in production environment.

Upvotes: 2

Daniel O'Hara
Daniel O'Hara

Reputation: 13438

The /app folder usually contains dynamic data, the /public folder contains static files. This was made for caching and performance. A Web-server can output files in the /public folder directly to the user, without additional Ruby calls. It also can cache static files, set various headers on them and so on.

Upvotes: 2

Related Questions