0
0
Ruby on Railsframework~10 mins

Public and assets folders in Ruby on Rails - Interactive Code Practice

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

Complete the code to serve static files from the public folder in Rails.

Ruby on Rails
Rails.application.config.serve_static_files = [1]
Drag options to blanks, or click blank then click option'
Atrue
Bnil
Cfalse
Dauto
Attempts:
3 left
💡 Hint
Common Mistakes
Using false disables serving static files.
Using nil or auto are not valid options here.
2fill in blank
medium

Complete the code to add a CSS file named style.css to the asset pipeline in Rails.

Ruby on Rails
Rails.application.config.assets.precompile += %w([1])
Drag options to blanks, or click blank then click option'
Aimage.png
Bapplication.js
Cstyle.css
Dreset.scss
Attempts:
3 left
💡 Hint
Common Mistakes
Adding JavaScript or image files instead of CSS.
Using wrong file extensions.
3fill in blank
hard

Fix the error in the code to correctly reference an image asset in a Rails view.

Ruby on Rails
<%= image_tag '[1]' %>
Drag options to blanks, or click blank then click option'
Alogo.png
Bassets/logo.png
C/assets/logo.png
Dpublic/logo.png
Attempts:
3 left
💡 Hint
Common Mistakes
Including folder paths like /assets/ or public/ causes errors.
Using incorrect file paths breaks image loading.
4fill in blank
hard

Fill both blanks to create a hash that maps asset names to their digest paths in Rails.

Ruby on Rails
assets = { '[1]' => '[2]' } # maps logical name to digest path
Drag options to blanks, or click blank then click option'
Aapplication.css
Bapplication-123abc.css
Clogo.png
Dlogo-456def.png
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping key and value.
Using non-digest filenames as values.
5fill in blank
hard

Fill all three blanks to write a Rails helper method that returns the full path for a given asset name.

Ruby on Rails
def asset_full_path(name)
  File.join(Rails.root, 'public', [1], [2] + name + [3])
end
Drag options to blanks, or click blank then click option'
Aassets
B/
C.
Dimages
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong folder names like 'images' instead of 'assets'.
Missing slashes or dots causing wrong paths.