Challenge - 5 Problems
Rails Assets Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Purpose of the public folder in Rails
What is the main role of the public folder in a Rails application?
Attempts:
2 left
💡 Hint
Think about files that the server can send without running Ruby code.
✗ Incorrect
The public folder holds static files like images, robots.txt, or favicon.ico that the web server can serve directly without involving Rails code.
❓ component_behavior
intermediate2: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?
Attempts:
2 left
💡 Hint
Consider how Rails prepares CSS and JavaScript files before sending them to the browser.
✗ Incorrect
Files in app/assets are processed by the asset pipeline. This allows Rails to preprocess, compress, and fingerprint them for caching.
📝 Syntax
advanced2: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
<%= ??? %>
Attempts:
2 left
💡 Hint
Think about the helper that generates an HTML
tag.
✗ Incorrect
image_tag generates an HTML element with the correct path to the asset. The others return just the URL or path string.
🔧 Debug
advanced2: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?Attempts:
2 left
💡 Hint
Think about what happens to assets when deploying to production.
✗ Incorrect
In production, Rails serves precompiled assets. If you add a new asset, you must recompile assets so the new file is included.
❓ state_output
expert3: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?Attempts:
2 left
💡 Hint
Remember how the web server handles files in public vs assets folders.
✗ Incorrect
Files in the public folder are served directly by the web server. Requests to /example.txt will return the public file, ignoring app/assets.