简体   繁体   中英

Difference between Public and View of ruby on rails

What are the exact difference between the functionalities of app/View part and Public part of ruby on rails.

It seems that similar type of assets like js functions etc are defined in both.

what are the reasons behind defining the same things twice

In the public directory, Rails stores only static assets, ie files which are sent to the client as is without any further processing. These files can be generated using the assets pipeline (eg javascript assets or CSS files). However, they are only generated once (typically) during deployment.

The views however are the templates used by rails to generate the response to a dynamic request. Thus, if a user requests a certain (dynamic) action from your application, your controller decides which view to render. Its output is then sent to the browser. The view can thus be highly dynamic so that their output can change for each request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM