Home »
MCQs
Ruby on Rails MCQs
Ruby on Rails MCQs: This section contains multiple-choice questions on Ruby on Rails. All MCQs have the correct answers and explanations. These MCQs will help students and professionals to test their skills and to enhance their knowledge of Ruby on Rails.
List of Ruby on Rails MCQs
1. Rails is ____.
- A web application framework
- A ORM tool
- A Library of Ruby
- Rails is a web application framework.
Answer: A) A web application framework
Explanation:
Ruby on Rails (Rails) is a web application framework.
Discuss this Question
2. Rails framework runs on which of the following programming language?
- Python
- Java
- Ruby
- Perl
Answer: C) Ruby
Explanation:
Rails is a web application framework running on the Ruby programming language.
Discuss this Question
3. Which of the following, creates a new application?
- $ rails latest
- $ rails now
- $ rails new
- $ rails create
Answer: C) $ rails new
Explanation:
$ rails new, create a new application.
Discuss this Question
4. The controllers, models, views, helpers, mailers, channels, tasks, and assets for your application are all located in which of the following folder?
- Config
- Public
- App
- temp
Answer: C) App
Explanation:
The controllers, models, views, helpers, mailers, channels, tasks, and assets for your application are all located in the app folder.
Discuss this Question
5. Which of the following folder has the Rails script that launches your application as well as any additional scripts you might need to install, configure, update, or otherwise manage your application?
- Config
- Temp
- Public
- Bin
Answer: D) Bin
Explanation:
The "Bin" folder has the Rails script that launches your application as well as any additional scripts you might need to install, configure, update, or otherwise manage your application.
Discuss this Question
6. Which of the following folder contains compiled assets and static files?
- Temp
- Static
- Public
- Bin
Answer: C) Public
Explanation:
The public folder contains compiled assets and static files.
Discuss this Question
7. Which of the following folder is a place for all third-party code?
- Rakefile
- Vendor
- Static
- App
Answer: B) Vendor
Explanation:
A vendor folder is a place for all third-party codes.
Discuss this Question
8. To terminate the web server, use ____ in the terminal window where it is currently operating.
- Ctrl+Q
- Ctrl+W
- Ctrl+S
- Ctrl+C
Answer: D) Ctrl+C
Explanation:
To terminate the web server, use Ctrl+C in the terminal window where it is currently operating.
Discuss this Question
9. In the development environment, does rails require you to restart the server?
- Yes
- No
Answer: B) No
Explanation:
Rails often does not require you to restart the server when working in the development environment.
Discuss this Question
10. Which of the following links a controller action to a request?
- Pipeline
- Route
- Model
- Link
Answer: B) Route
Explanation:
A route links a controller action to a request.
Discuss this Question
11. Which of the following handles the request and prepares any relevant data for the view?
- Model
- Controller
- View
- Route
Answer: B) Controller
Explanation:
A controller action handles the request and prepares any relevant data for the view.
Discuss this Question
12. A ____ presents information in the specified format.
- View
- Modal
- Window
Answer: A) View
Explanation:
A view presents information in the specified format.
Discuss this Question
13. Views are templates that are often created using a combination of HTML and Ruby. True or false?
- True
- False
Answer: A) True
Explanation:
Views are templates that are often created using a combination of HTML and Ruby.
Discuss this Question
14. Routes are rules written in a ____.
- HTTP protocols
- Python
- TCP
- Ruby DSL (Domain-Specific Language).
Answer: D) Ruby DSL (Domain-Specific Language).
Explanation:
Routes are rules written in a Ruby DSL (Domain-Specific Language).
Discuss this Question
15. Does Rails applications use require to load application code?
- Yes
- No
Answer: B) No
Explanation:
Rails applications do not use require to load application code.
Discuss this Question
16. A ____ is a Ruby class that is used to represent data.
- View
- Param
- Model
Answer: C) Model
Explanation:
The root segment is the segment that sits at the top of the hierarchy.
Discuss this Question
17. ____ are used to change the database structure of an application.
- Migrate
- Transitions
- Migrations
Answer: C) Migrations
Explanation:
Migrations are used to change the database structure of an application.
Discuss this Question
18. In Rails applications, migrations are written in ____.
- Ruby
- Python
- Perl
- C#
Answer: A) Ruby
Explanation:
To provide database independence, migrations in Rails applications are written in Ruby.
Discuss this Question
19. Rails provides a routes method named ____ that maps all of the conventional routes for a collection of resources.
- Require
- Resources
- Options
- Maps
Answer: B) Resources
Explanation:
Rails provides a route method named resources that maps all of the conventional routes for a collection of resources.
Discuss this Question
20. We can inspect what routes are mapped by running which of the following command?
- bin/rails routes
- bin/rails routing mapped
- bin/rails mapped
- bin/rails route_mapped
Answer: A) bin/rails routes
Explanation:
We can inspect what routes are mapped by running the bin/rails routes command.
Discuss this Question
21. Which of the following statement is True?
- Statement 1: Render triggers a new request from the browser.
- Statement 2: render will render the supplied view for the current request.
Answer: B) Statement 2: render will render the supplied view for the current request.
Explanation:
Statement 2 is correct i.e., render will render the supplied view for the current request.
Discuss this Question
22. To develop our form, we'll utilize a Rails functionality known as a ____.
- Form Generator
- Form Creator
- Form decorator
- Form builder
Answer: D) Form builder
Explanation:
To develop our form, we'll utilize a Rails functionality known as a form builder.
Discuss this Question
23. To assist us to cope with erroneous user input, Rails has a feature called ____.
- Vitiate
- Corroborate
- Validations
- Retrospect
Answer: C) Validations
Explanation:
To assist us to cope with erroneous user input, Rails has a feature called validations.
Discuss this Question
24. ____ returns true if this object has been destroyed, otherwise returns false.
- Destroy()
- Destroy!()
- Delete!()
- Destroyed?()
Answer: D) Destroyed?()
Explanation:
destroyed?() returns true if this object has been destroyed, otherwise returns false.
Discuss this Question
25. Does the delete statement also deletes the records marked as #readonly?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, the delete statement will also delete the records marked as #readonly.
Discuss this Question
26. Which of the following statement is True?
- Statement 1: redirect_to will trigger a new request from the browser.
- Statement 2: redirect_to will render the supplied view for the current request.
Answer: A) Statement 1: redirect_to will trigger a new request from the browser.
Explanation:
Statement 1 is correct i.e., redirect_to will trigger a new request from the browser.
Discuss this Question
27. There is no callback execution, and the row is simply deleted with an SQL ____ statement.
- DELETE
- DESTROY
- DELETE!
- DESTROY!
Answer: A) DELETE
Explanation:
There is no callback execution, and the row is simply deleted with an SQL DELETE statement.
Discuss this Question
28. What is the difference between destroy and delete?
- Delete runs any callbacks on the model while Destroy doesn't.
- Destroy runs any callbacks on the model while Delete doesn't.
Answer: B) Destroy runs any callbacks on the model while Delete doesn't.
Explanation:
Destroy and delete differ in a certain that destroy executes any callbacks on the model while delete does not.
Discuss this Question
29. Which of the following updates a single attribute and saves the record?
- update_columns(attributes)
- update!(attributes)
- update_column(name, value)
- update_attribute(name, value)
Answer: D) update_attribute(name, value)
Explanation:
update_attribute(name, value) updates a single attribute and saves the record.
Discuss this Question
30. ____ uses an UPDATE SQL query to make changes to the attributes directly in the database and sets them in the receiver.
- update_columns(attributes)
- update!(attributes)
- update_column(name, value)
- update_attribute(name, value)
Answer: A) update_columns(attributes)
Explanation:
update columns(attributes) uses an UPDATE SQL query to make changes to the attributes directly in the database and sets them in the receiver:
Discuss this Question
31. Which of the following is the fastest way to update attributes?
- update_columns(attributes)
- update!(attributes)
- update_column(name, value)
- update_attribute(name, value)
Answer: A) update_columns(attributes)
Explanation:
update columns(attributes) is the fastest way to update attributes because it goes straight to the database.
Discuss this Question
32. Rails offers how many built-in assertions which are designed to make testing routes simpler?
- 5
- 4
- 3
- 2
Answer: C) 3
Explanation:
To make testing routes easier, Rails comes with three built-in assertions:
- assert_generates
- assert_recognizes
- assert_routing
Discuss this Question
33. Which of the following can be used with default routes or custom routes, and it claims that a specific set of options produces a specific path?
- assert_generates
- assert_recognizes
- assert_routing
Answer: A) assert_generates
Explanation:
Assert_generates can be used with default routes or custom routes, and it claims that a specific set of options produces a specific path.
Discuss this Question
34. Among assert_recognizes and assert_routing which of the following is the inverse of assert_generates?
- assert_recognizes
- assert_routing
Answer: A) assert_recognizes
Explanation:
assert_recognizes is the inverse of assert_generates.
Discuss this Question
35. Which of the following option allows you to override the named route helper names that are typically used?
- :over
- :method
- :as
- :override
Answer: C) :as
Explanation:
The :as option allows you to override the named route helper names that are typically used.
Discuss this Question
36. ____ allow the program to keep track of user-specific data while users engage with it.
- Transactions
- Sessions
- Cycles
Answer: B) Sessions
Explanation:
Sessions allow the program to keep track of user-specific data while users engage with it.
Discuss this Question
37. Which of the following assertion verifies the route in both directions: it verifies that both the path and the options are generated?
- assert_generates
- assert_recognizes
- assert_routing
Answer: C) assert_routing
Explanation:
The assert_routing assertion verifies the route in both directions: it verifies that both the path and the options are generated.
Discuss this Question
38. Cookies have a size limit of ____.
- 10KB
- 100KB
- 4KB
Answer: C) 4KB
Explanation:
Cookies have a size limit of 4 kB.
Discuss this Question
39. You can redirect any path to another path by using the ____ helper in your router.
- Divert
- Pass
- Routes
- Redirect
Answer: D) Redirect
Explanation:
You can redirect any path to another path by using the redirect helper in your router.
Discuss this Question
40. With the ____ option, you can specifically designate a controller to use for the resource.
- :routingengine
- :redirect
- :path
- :controller
Answer: D) :controller
Explanation:
With the :controller option, you can specifically designate a controller to use for the resource.
Discuss this Question
41. Cookies are stored on the ____.
- Client-side
- Server-side
Answer: A) Client-side
Explanation:
Cookies are stored on the client-side.
Discuss this Question
42. Cookies are ____ by nature.
- Permanent
- Temporary
Answer: B) Temporary
Explanation:
Cookies are temporary by nature.
Discuss this Question
43. Rails ____ cookies by default?
- Decrypt
- Encrypt
- None
Answer: B) Encrypt
Explanation:
By default, Rails encrypts cookies. Without compromising the cookie's encryption, the client is unable to view or modify its information.
Discuss this Question
44. The ____ command combines the results of two SQL searches into a single set.
- Intersection
- Append
- Union
Answer: C) Union
Explanation:
The UNION command combines the results of two SQL searches into a single set.
Discuss this Question
45. An ____ attack involves injecting malicious code or parameters into a web application to run it within a secure environment
- Hijacking
- CSRF
- Injection
Answer: C) Injection
Explanation:
An injection attack involves injecting malicious code or parameters into a web application to run it within a secure environment.
Discuss this Question
46. To remove an attachment from a model, use the ____ command on the attachment.
- Revoke
- Remove
- Delete
- Purge
Answer: D) Purge
Explanation:
To remove an attachment from a model, use the purge command on the attachment.
Discuss this Question
47. Active Storage supports how many ways to serve files?
- 2
- 3
- 4
- 5
Answer: A) 2
Explanation:
Active Storage supports two ways to serve files: redirecting and proxying.
Discuss this Question
48. All Active Storage controllers are ____ by default.
- Privately accessible
- Publicly accessible
Answer: B) Publicly accessible
Explanation:
All Active Storage controllers are publicly accessible by default.
Discuss this Question
49. Rails offers how many standard spots to place initialization code?
- 2
- 3
- 4
- 5
Answer: D) 5
Explanation:
Rails offers four standard spots to place initialization code:
- config/application.rb
- Environment-specific configuration files
- Initializers
- After-initializers
Discuss this Question
50. Which method is used to specify a filter that is executed before to a controller action?
- before_router
- before_action
- before_engine
- before_component
Answer: B) before_action
Explanation:
before_action method is used to specify a filter that is executed before a controller action.
Discuss this Question
51. Instance variable in Ruby begins with ____.
- @@
- @
- &
- __
Answer: B) @
Explanation:
The instance Variable in Ruby begins with @ symbol.
Discuss this Question
52. Which of the following inheritance does Ruby support?
- Multilevel
- Multiple
- Hierarchical
- Single
- All of the above
Answer: D) Single
Explanation:
Ruby only supports single inheritance.
Discuss this Question
53. CSRF stands for ____.
- Combine system request forgery
- Crucial site render forgery
- Cross-site render forgery
- Cross-site request forgery
Answer: D) Cross-site request forgery
Explanation:
CSRF stands for Cross-Site Request Forgery.
Discuss this Question
54. ____ is a sort of attack when the attacker sends a form to a separate website on your behalf that might result in harm or the disclosure of sensitive data.
- Crypto-jacking
- CSRF
- DDOS
- Injection
Answer: B) CSRF
Explanation:
CSRF is a sort of attack when the attacker sends a form to a separate website on your behalf that might result in harm or the disclosure of sensitive data.
Discuss this Question
55. Class variable in Ruby begins with ____.
- @@
- @
- &
- __
Answer: A) @@
Explanation:
Class Variable in Ruby begins with @@ symbol.
Discuss this Question
56. Is Ruby an object-oriented programming language?
- Yes
- No
Answer: A) Yes
Explanation:
Ruby is an object-oriented programming language inspired by PERL and Python.
Discuss this Question
57. Global variable in Ruby begins with ____.
- @@
- $$
- &
- $
Answer: D) $
Explanation:
Global Variable in Ruby begins with $ symbol.
Discuss this Question
58. ____ are modules that offer techniques that your view can use right away.
- Component
- Assertions
- Helpers
Answer: C) Helpers
Explanation:
Helpers are modules that offer techniques that your view can use right away.
Discuss this Question
59. Which of the following access modifiers are not used in Ruby?
- Public
- Private
- Protected
- None
Answer: D) None
Explanation:
Ruby has three access modifiers: public, protected, and private.
Discuss this Question
60. In Ruby, the scaffolding is done automatically?
- True
- False
Answer: A) True
Explanation:
In Ruby, the scaffolding is done automatically.
Discuss this Question
61. Which of the following type of variable is available in the Ruby class?
- Local Variables
- Global Variables
- Class Variables
- Instance Variables
- All of the above
Answer: E) All of the above
Explanation:
Types of variables available in Ruby Class are,
- Local Variables
- Global Variables
- Class Variables
- Instance Variables
Discuss this Question
62. When a model object changes, ____ are in charge of terminating or expiring caches.
- Injectors
- Janitors
- Sweepers
Answer: C) Sweepers
Explanation:
When a model object changes, sweepers are in charge of terminating or expiring caches.
Discuss this Question
63. Plugins are installed ____.
- In the application folder
- On a machine
Answer: A) In the application folder
Explanation:
The plugin is also ruby code, it is installed in the application folder and only available for that specific application.
Discuss this Question
64. Ruby ____ is a technique for adding a string to a literal.
- Interpolation
- Substitution
- Injection
Answer: A) Interpolation
Explanation:
Ruby interpolation is a technique for adding a string to a literal.
Discuss this Question
65. What is a gem?
- A gem is a just ruby code that is installed on a machine
- A gem is a just ruby code that is installed in the application folder
Answer: A) A gem is a just ruby code that is installed on a machine
Explanation:
A gem is a just ruby code that is installed on a machine and accessible to any Ruby programs running on that computer.
Discuss this Question