0
0
Ruby on Railsframework~30 mins

Rails vs Django vs Express comparison - Hands-On Comparison

Choose your learning style9 modes available
Build a Simple Web App with Rails, Django, and Express
📖 Scenario: You want to create a simple web app that shows a list of books with their titles and authors. You will build this app using three popular web frameworks: Rails (Ruby), Django (Python), and Express (JavaScript). This will help you understand how each framework handles data setup, configuration, core logic, and final output.
🎯 Goal: Build a simple web app that displays a list of books with their titles and authors using Rails, Django, and Express. Learn the differences in how these frameworks structure data, configure settings, handle core logic, and render output.
📋 What You'll Learn
Create a data structure to hold book information
Add a configuration variable for minimum author name length
Filter books based on the author name length
Render the filtered list of books in the web app
💡 Why This Matters
🌍 Real World
Web developers often need to choose between frameworks like Rails, Django, and Express. Building the same app in each helps understand their differences and strengths.
💼 Career
Knowing how to set up data, configure variables, apply core logic, and render output in popular frameworks is essential for backend and full-stack developer roles.
Progress0 / 4 steps
1
DATA SETUP: Create a list of books
In your Rails controller, create a variable called @books that holds an array of hashes. Each hash should have the keys :title and :author with these exact entries: { title: 'The Hobbit', author: 'J.R.R. Tolkien' }, { title: '1984', author: 'George Orwell' }, and { title: 'To Kill a Mockingbird', author: 'Harper Lee' }.
Ruby on Rails
Need a hint?

Use an instance variable @books and assign it an array of hashes with the exact book details.

2
CONFIGURATION: Set minimum author name length
Add a variable called min_author_length and set it to 10 in your Rails controller. This will be used to filter authors with names longer than 10 characters.
Ruby on Rails
Need a hint?

Just create a variable min_author_length and assign it the number 10.

3
CORE LOGIC: Filter books by author name length
Create a variable called @filtered_books that holds only the books from @books where the author's name length is greater than min_author_length. Use the select method with a block that checks book[:author].length > min_author_length.
Ruby on Rails
Need a hint?

Use select on @books and check if book[:author].length is greater than min_author_length.

4
COMPLETION: Render filtered books in the view
In your Rails view file, use an each loop to go through @filtered_books. For each book, display the title inside an <h2> tag and the author inside a <p> tag.
Ruby on Rails
Need a hint?

Use ERB tags to loop through @filtered_books and display the title and author inside HTML tags.