How do you execute raw SQL queries in ActiveRecord?
Anonymous Quiz
69%
execute
8%
raw_query
20%
find_by_sql
3%
query
What does the DB.transaction block in the Sequel gem do?
Anonymous Quiz
3%
Automatically commits changes without rollback
2%
Filters records within a query
6%
Runs raw SQL queries
89%
Starts a database transaction and rolls back on failure
How do you rollback a migration in Rails?
Anonymous Quiz
2%
rails db:migrate:undo
1%
rails db:reverse
91%
rails db:rollback
6%
rails migrate:rollback
🔥4👎1
Which gem is commonly used in Ruby to manage PostgreSQL-specific features like JSONB and arrays?
Anonymous Quiz
18%
ActiveRecord
72%
Pg
7%
Sequel
3%
Redis
👍2
In a service-oriented architecture, how can you ensure loose coupling between services in Ruby?
Anonymous Quiz
62%
Use dependency injection to pass dependencies into services
5%
Use global variables to share data between services
15%
Use a Singleton to manage shared state
18%
Avoid using interfaces between services
🥱3🤯1
What is the purpose of using the Repository pattern in a Ruby application?
Anonymous Quiz
20%
To store objects in memory for faster processing
8%
To manage database migrations in ActiveRecord
66%
To abstract data access logic from the business logic
7%
To define relationships between models
👍2
In a Ruby application using the Command pattern, what is the main advantage of encapsulating a request as an object?
Anonymous Quiz
9%
Making the application faster by executing commands directly
54%
Decoupling the sender from the receiver and making commands easier to queue or log
20%
Replacing service objects with simpler structures
17%
Avoiding the need for middleware
🥴6
Which of these is NOT valid Ruby syntax?
Anonymous Quiz
28%
x = ->(a, b) { a + b }
57%
y = { |x| x * 2 }
5%
z = Proc.new { |n| n ** 2 }
9%
a, b = [1, 2]
Which of these Ruby keywords is NOT related to exception handling?
Anonymous Quiz
3%
rescue
42%
catch
7%
raise
16%
ensure
32%
retry
What is the primary benefit of using Interactors (e.g., the Interactor gem) in a Ruby application?
Anonymous Quiz
10%
Replacing controllers with simpler classes
6%
Simplifying database queries
1%
Generating migration files dynamically
83%
Encapsulating a single use-case into a reusable and testable object
What does the pluck method do in ActiveRecord?
Anonymous Quiz
94%
Retrieves specific fields from the database as an array
2%
Deletes a record from the database
1%
Сreates an index for a field
3%
Joins multiple tables in a query.
How can you create a composite index in Rails?
Anonymous Quiz
4%
By creating separate indices for each column
75%
By specifying multiple columns in a single add_index call
11%
By adding the :composite option in the model
11%
Composite indices are not supported in Rails.
Forwarded from Ruby Interview | Ruby on Rails
What will this query return?
Anonymous Quiz
16%
This query will result in an error.
6%
Names and total order count for all records.
4%
Names with fewer than 5 orders.
74%
All names with more than 5 orders.
Forwarded from Ruby Interview | Ruby on Rails
What is the output of the following Ruby code?
Anonymous Quiz
41%
[2, 3, 4]
52%
[1, 2, 3]
6%
No output, error occurs
1%
[1, 2, 3, 4]
How do you create an empty hash in Ruby?
Anonymous Quiz
0%
empty_hash = ()
3%
empty_hash = []
80%
empty_hash = {}
17%
empty_hash = hash.new