Challenge - 5 Problems
Sprockets Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
What is the primary role of the Sprockets asset pipeline in Rails?
Choose the best description of what the Sprockets asset pipeline does in a Rails application.
Attempts:
2 left
💡 Hint
Think about how Rails prepares files like CSS and JavaScript before sending them to the browser.
✗ Incorrect
The Sprockets asset pipeline processes and optimizes static assets like CSS and JavaScript by compiling, concatenating, and minifying them. This helps the browser load pages faster.
❓ component_behavior
intermediate1:30remaining
What happens when you add a new JavaScript file in app/assets/javascripts and reference it in application.js manifest?
Given a new file named custom.js added to app/assets/javascripts and included via //= require custom in application.js, what is the expected behavior when the Rails app runs in production mode?
Attempts:
2 left
💡 Hint
Consider how Sprockets bundles JavaScript files listed in the manifest.
✗ Incorrect
Files required in the application.js manifest are concatenated and compiled into one bundle for efficient delivery in production.
📝 Syntax
advanced1:30remaining
Identify the correct Sprockets directive syntax to include all JavaScript files in a folder
Which option correctly uses a Sprockets directive to include all JavaScript files in the current directory inside application.js?
Ruby on Rails
// application.js manifest file
Attempts:
2 left
💡 Hint
Look for the directive that recursively includes files in the directory.
✗ Incorrect
The directive //= require_tree . tells Sprockets to include all files in the current directory and its subdirectories.
🔧 Debug
advanced2:00remaining
Why does a CSS change not appear in production after precompilation?
You updated styles in app/assets/stylesheets/custom.css but after running rails assets:precompile and deploying, the changes do not show in production. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check if the file is referenced in the manifest or precompile configuration.
✗ Incorrect
If a CSS file is not referenced in application.css or listed in config.assets.precompile, it won't be compiled and served in production.
❓ state_output
expert2:00remaining
What is the fingerprinted filename generated by Sprockets for app.js after precompilation?
If you have a file app/assets/javascripts/app.js and run rails assets:precompile, what will the compiled filename look like in public/assets?
Attempts:
2 left
💡 Hint
Sprockets adds a hash fingerprint to filenames for cache busting.
✗ Incorrect
Sprockets appends a unique hash fingerprint to asset filenames during precompilation to help browsers cache assets effectively.