0
0
Ruby on Railsframework~30 mins

Why Ruby on Rails exists - See It in Action

Choose your learning style9 modes available
Why Ruby on Rails Exists
📖 Scenario: Imagine you want to build a website that helps people share their favorite recipes. You want it to be fast to build and easy to change later.
🎯 Goal: You will create a simple Ruby on Rails project that shows why Rails exists by setting up a basic data structure, adding a configuration, applying core Rails logic, and completing the setup to display a list of recipes.
📋 What You'll Learn
Create a Ruby hash called recipes with exact recipe names and descriptions
Add a configuration variable called show_descriptions set to true
Use a Rails view loop to display recipe names and descriptions only if show_descriptions is true
Complete the Rails view with proper HTML structure and Rails tags
💡 Why This Matters
🌍 Real World
Ruby on Rails helps developers build websites quickly by providing ready tools to handle data, views, and user interaction in a clean way.
💼 Career
Understanding why Rails exists and how to use its core features is essential for web developers working with Ruby on Rails to build maintainable and fast web applications.
Progress0 / 4 steps
1
DATA SETUP: Create the recipes hash
Create a Ruby hash called recipes with these exact entries: 'Pancakes' => 'Fluffy and light', 'Spaghetti' => 'Classic Italian pasta', and 'Salad' => 'Fresh and healthy'.
Ruby on Rails
Need a hint?

Use a Ruby hash with string keys and string values exactly as shown.

2
CONFIGURATION: Add a show_descriptions variable
Add a Ruby variable called show_descriptions and set it to true.
Ruby on Rails
Need a hint?

Just create a variable named show_descriptions and assign it the value true.

3
CORE LOGIC: Use a Rails view loop to display recipes
In a Rails view file, use recipes.each do |name, description| to loop through the recipes. Inside the loop, display the name in an <h2> tag. If show_descriptions is true, display the description in a <p> tag.
Ruby on Rails
Need a hint?

Use ERB tags to loop and conditionally display descriptions.

4
COMPLETION: Wrap the view in a proper HTML structure
Add a <section> tag around the recipes loop and include a <header> with <h1>Recipe List</h1> above the loop.
Ruby on Rails
Need a hint?

Wrap the loop inside semantic HTML tags for better structure and accessibility.