0
0
Ruby on Railsframework~5 mins

Public and assets folders in Ruby on Rails - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the public folder in a Rails application?
The public folder holds static files like images, robots.txt, and favicon.ico that are served directly by the web server without going through Rails.
Click to reveal answer
beginner
Where should you put CSS, JavaScript, and image files that need preprocessing in Rails?
These files belong in the app/assets folder because Rails processes them with tools like the asset pipeline before serving.
Click to reveal answer
intermediate
How does Rails handle files in the public folder differently from those in app/assets?
Files in public are served as-is, no processing. Files in app/assets are compiled, minified, and fingerprinted by the asset pipeline before serving.
Click to reveal answer
intermediate
What is the benefit of fingerprinting assets in Rails?
Fingerprinting adds a unique hash to filenames to help browsers cache assets efficiently and update them only when the file changes.
Click to reveal answer
beginner
Can you put dynamic Ruby code inside files in the public folder?
No. Files in public are static and served directly. Dynamic Ruby code belongs in views or helpers, not in public.
Click to reveal answer
Which folder in Rails is used for static files served without processing?
Apublic
Bapp/assets
Cconfig
Dlib
Where do you place JavaScript files that need to be compiled by Rails?
Abin
Bpublic
Capp/assets
Dtmp
What does fingerprinting in Rails asset pipeline help with?
AImproving database queries
BCaching assets efficiently
CGenerating HTML templates
DRunning background jobs
Can you put ERB (Ruby code) inside files in the public folder?
ANo, files are served as static
BYes, it will be processed
COnly if the file is .html.erb
DOnly in development mode
Which folder is best for storing images that need to be optimized by Rails?
Alog
Bpublic
Cvendor
Dapp/assets/images
Explain the difference between the public folder and the app/assets folder in Rails.
Think about how files are served and processed.
You got /4 concepts.
    Why is fingerprinting important for assets in Rails? How does it affect caching?
    Consider how browsers decide to use cached files or fetch new ones.
    You got /4 concepts.