0
0
Ruby on Railsframework~20 mins

Sprockets asset pipeline in Ruby on Rails - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sprockets Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1: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.
AIt handles user authentication and session management.
BIt manages database migrations and schema changes automatically.
CIt generates HTML views from controller data.
DIt compiles, concatenates, and minifies CSS, JavaScript, and image assets for efficient delivery.
Attempts:
2 left
💡 Hint
Think about how Rails prepares files like CSS and JavaScript before sending them to the browser.
component_behavior
intermediate
1: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?
Acustom.js causes a runtime error because it is not precompiled separately.
Bcustom.js is ignored because only files in vendor/assets are compiled.
Ccustom.js is compiled and included in the application.js bundle served to the browser.
Dcustom.js is served as a separate file without being bundled.
Attempts:
2 left
💡 Hint
Consider how Sprockets bundles JavaScript files listed in the manifest.
📝 Syntax
advanced
1: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
A//= require_tree .
B//= include_all .
C//= require_directory .
D//= import * from '.'
Attempts:
2 left
💡 Hint
Look for the directive that recursively includes files in the directory.
🔧 Debug
advanced
2: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?
AThe custom.css file was not included in the application.css manifest or precompile list.
BThe CSS syntax is invalid causing the file to be skipped during precompilation.
CThe browser cache is disabled, so changes are not reflected.
DSprockets does not support CSS files in app/assets/stylesheets.
Attempts:
2 left
💡 Hint
Check if the file is referenced in the manifest or precompile configuration.
state_output
expert
2: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?
Aapp_bundle.js
Bapp-3a1b2c4d5e6f7g8h9i0j.js
Capp.min.js
Dapp.js
Attempts:
2 left
💡 Hint
Sprockets adds a hash fingerprint to filenames for cache busting.