Recall & Review
beginner
What is an action method in a Rails controller?
An action method is a public method inside a Rails controller that responds to a web request and renders a view or redirects the user.
Click to reveal answer
beginner
How does Rails know which action method to call for a URL?
Rails uses routing rules defined in config/routes.rb to map URLs to specific controller action methods.
Click to reveal answer
intermediate
What happens if an action method does not explicitly render or redirect?
Rails automatically renders a view template matching the action method name unless you specify otherwise.
Click to reveal answer
intermediate
Can private methods in a Rails controller be used as action methods?
No, only public methods can be action methods. Private or protected methods cannot be called as actions from a web request.
Click to reveal answer
advanced
Why should action methods be kept simple and focused?
Keeping action methods simple improves readability, maintainability, and helps separate concerns by moving complex logic to models or helpers.
Click to reveal answer
Which of the following is true about Rails action methods?
✗ Incorrect
Action methods are public controller methods that handle requests and render or redirect.
What file defines the URL to action method mapping in Rails?
✗ Incorrect
Routes in config/routes.rb map URLs to controller action methods.
If an action method does not call render or redirect, what does Rails do?
✗ Incorrect
Rails automatically renders the view template matching the action method name.
Which methods cannot be used as action methods in Rails?
✗ Incorrect
Only public methods in controllers can be action methods.
Why is it good practice to keep action methods simple?
✗ Incorrect
Simple action methods make code easier to read and maintain.
Explain what an action method is in Rails and how it relates to routing and views.
Think about how a URL leads to a method that shows a page.
You got /4 concepts.
Describe why private methods cannot be action methods and how to organize controller code effectively.
Consider access control and code clarity.
You got /4 concepts.