0
0
Ruby on Railsframework~20 mins

Asset pipeline basics in Ruby on Rails - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Asset Pipeline Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What is the output of this asset pipeline manifest?
Given this application.js manifest file in a Rails app, what JavaScript files will be included in the compiled asset?
Ruby on Rails
//= require jquery
//= require_tree ./modules
//= require_self
console.log('App loaded');
AIncludes only files in modules folder and application.js code, excludes jquery.js
BIncludes only jquery.js and application.js code, ignores modules folder
CIncludes jquery.js, all files in modules folder, then the code in application.js itself
DIncludes jquery.js and application.js code, but modules folder files are loaded after application.js
Attempts:
2 left
💡 Hint
Remember that require_tree includes all files in the specified folder in alphabetical order.
📝 Syntax
intermediate
1:30remaining
Which option correctly compiles SCSS with asset pipeline?
You want to import a partial SCSS file named _buttons.scss into application.scss. Which import statement is correct?
A@import 'buttons';
B@import 'buttons.scss';
C@import '_buttons.scss';
D@import '_buttons';
Attempts:
2 left
💡 Hint
Partial SCSS files start with underscore and are imported without underscore or extension.
🔧 Debug
advanced
2:30remaining
Why does this asset not load in production?
You have a JavaScript file custom.js included in your manifest, but it doesn't load in production. The manifest is:
//= require jquery
//= require custom
//= require_tree .

What is the most likely cause?
AThe <code>jquery</code> file must be required after <code>custom</code> for it to load
BThe <code>require_tree .</code> line overrides the <code>require custom</code> line, so custom.js is ignored
CThe manifest file must end with <code>require_self</code> to include custom.js
DThe file <code>custom.js</code> is missing from the assets precompile list in production config
Attempts:
2 left
💡 Hint
Check if the asset is included in the precompile list for production environment.
state_output
advanced
2:00remaining
What is the output of this ERB asset tag in production?
Given this ERB in a Rails view:
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

What will be the rendered HTML output in production mode?
A<script src="/assets/application.js"></script>
B<script src="/assets/application-abc123.js" data-turbolinks-track="reload"></script>
C<script src="/javascripts/application.js" data-turbolinks-track="reload"></script>
D<script src="/assets/application.js" data-turbolinks-track="reload"></script>
Attempts:
2 left
💡 Hint
In production, Rails appends a digest hash to asset filenames for caching.
🧠 Conceptual
expert
3:00remaining
How does the asset pipeline improve web app performance?
Which of the following best explains how the Rails asset pipeline helps improve performance for users?
AIt combines, minifies, and fingerprints assets to reduce requests, file size, and enable caching
BIt automatically converts all assets to WebP format for faster loading
CIt loads assets asynchronously by default to prevent blocking page rendering
DIt stores assets in the database to speed up retrieval
Attempts:
2 left
💡 Hint
Think about how fewer and smaller files help browsers load pages faster.