0
0
Ruby on Railsframework~10 mins

Rails vs Django vs Express comparison - Interactive Practice

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

Complete the code to create a new Rails controller named 'PostsController'.

Ruby on Rails
class PostsController < [1]
  def index
    # code here
  end
end
Drag options to blanks, or click blank then click option'
AApplicationController
BBaseController
CMainController
DRootController
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent base controller like BaseController.
2fill in blank
medium

Complete the code to define a Django view function that returns a simple HTTP response.

Ruby on Rails
from django.http import HttpResponse

def hello(request):
    return [1]('Hello, Django!')
Drag options to blanks, or click blank then click option'
AHttpRequest
BHttpView
CHttpResponse
DHttpServer
Attempts:
3 left
💡 Hint
Common Mistakes
Using HttpRequest instead of HttpResponse.
3fill in blank
hard

Fix the error in this Express.js route handler to send a JSON response.

Ruby on Rails
app.get('/api/data', (req, res) => {
  res.[1]({ message: 'Hello from Express!' });
});
Drag options to blanks, or click blank then click option'
AsendJson
Bjson
CsendText
DsendResponse
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like sendJson or sendText.
4fill in blank
hard

Fill both blanks to create a Rails route that maps GET requests for '/articles' to the 'index' action of 'ArticlesController'.

Ruby on Rails
Rails.application.routes.draw do
  [1] '[2]', to: 'articles#index'
end
Drag options to blanks, or click blank then click option'
Aget
Bpost
Cput
Darticles
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST or PUT instead of GET for reading data.
5fill in blank
hard

Fill all three blanks to create an Express.js middleware that logs the request method and URL, then calls next middleware.

Ruby on Rails
app.use(([1], [2], [3]) => {
  console.log(`$[1].method } $[1].url`);
  [3]();
});
Drag options to blanks, or click blank then click option'
Areq
Bres
Cnext
Drequest
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing parameter names or forgetting to call next().