0
0
Ruby on Railsframework~10 mins

Why asset management matters in Ruby on Rails - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to include the main CSS file in a Rails view.

Ruby on Rails
<%= stylesheet_link_tag '[1]', media: 'all' %>
Drag options to blanks, or click blank then click option'
Astyle
Bmain
Capplication
Ddefault
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent stylesheet name.
Forgetting to include the file extension.
2fill in blank
medium

Complete the code to include a JavaScript file in a Rails view.

Ruby on Rails
<%= javascript_include_tag '[1]' %>
Drag options to blanks, or click blank then click option'
Aapplication
Bscript
Cmain
Ddefault
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect file names.
Omitting the helper method.
3fill in blank
hard

Fix the error in the asset pipeline configuration to precompile additional assets.

Ruby on Rails
Rails.application.config.assets.precompile += ['[1]']
Drag options to blanks, or click blank then click option'
Amain.js
Bcustom.js
Capplication.css
Dstyle.css
Attempts:
3 left
💡 Hint
Common Mistakes
Adding default files unnecessarily.
Using incorrect file names.
4fill in blank
hard

Fill both blanks to create a helper method that returns the path to an asset and its digest fingerprint.

Ruby on Rails
def asset_path(name)
  Rails.application.assets.[1].digest_path(name) || [2]
end
Drag options to blanks, or click blank then click option'
Amanifest
Basset_manifest
Cassets
Dasset_pipeline
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method or object names.
Confusing asset pipeline terms.
5fill in blank
hard

Fill all three blanks to configure Rails to serve static assets with cache control headers.

Ruby on Rails
Rails.application.config.public_file_server.[1] = true
Rails.application.config.public_file_server.headers = {
  'Cache-Control' => '[2]',
  'Expires' => [3]
}
Drag options to blanks, or click blank then click option'
Aenabled
BCache-Control: max-age=31536000, public
C1.year.from_now.httpdate
Dcache_enabled
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong config keys.
Incorrect header formats.
Not enabling static file serving.