0
0
Ruby on Railsframework~20 mins

Public and assets folders in Ruby on Rails - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Rails Assets Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Purpose of the public folder in Rails
What is the main role of the public folder in a Rails application?
AIt contains Ruby source code files for models and controllers.
BIt holds compiled assets like JavaScript and CSS after precompilation.
CIt stores static files that are served directly by the web server without Rails processing.
DIt is used to store database migration files.
Attempts:
2 left
💡 Hint
Think about files that the server can send without running Ruby code.
component_behavior
intermediate
2:00remaining
Behavior of assets in the assets folder
Which statement best describes how files in the app/assets folder are handled in a Rails app?
AThey contain only Ruby code for asset management.
BThey are served directly by the web server without any processing.
CThey are ignored by Rails and must be manually copied to the public folder.
DThey are compiled and served through the asset pipeline, allowing preprocessing and fingerprinting.
Attempts:
2 left
💡 Hint
Consider how Rails prepares CSS and JavaScript files before sending them to the browser.
📝 Syntax
advanced
2:00remaining
Correct asset reference in Rails views
Which option correctly references an image named logo.png stored in app/assets/images inside a Rails ERB view?
Ruby on Rails
<%= ??? %>
A<%= asset_path('logo.png') %>
B<%= image_tag 'logo.png' %>
C<%= image_path('logo.png') %>
D<%= image_url('logo.png') %>
Attempts:
2 left
💡 Hint
Think about the helper that generates an HTML tag.
🔧 Debug
advanced
2:00remaining
Why is a new image not showing in production?
You added new_image.png to app/assets/images but it does not appear in production after deployment. What is the most likely cause?
AThe asset pipeline was not recompiled, so the new image is missing in the precompiled assets.
BThe image file is in the wrong folder; it should be in public/images.
CRails does not support PNG images in assets.
DThe image tag helper is deprecated and does not work.
Attempts:
2 left
💡 Hint
Think about what happens to assets when deploying to production.
state_output
expert
3:00remaining
Result of accessing a file in public vs assets folder
Given a file named example.txt placed in both public and app/assets folders, what happens when a browser requests /example.txt in production?
AThe file from the public folder is served directly; the asset pipeline ignores the request.
BThe asset pipeline serves the file from app/assets with fingerprinting applied.
CRails returns a 404 error because the file exists in two places.
DThe file from app/assets is served without fingerprinting.
Attempts:
2 left
💡 Hint
Remember how the web server handles files in public vs assets folders.