How do you retrieve all users whose name starts with "A" using ActiveRecord?
Anonymous Quiz
77%
User.where("name LIKE 'A%'")
8%
User.find_by(name: 'A%')
4%
User.get_all(name: /^A/)
10%
User.select("name LIKE 'A%'")
What does before_action :authenticate_user! do in a Rails controller?
Anonymous Quiz
3%
Automatically logs in the user
96%
Calls authenticate_user! before executing any action in the controller
0%
Runs only after the controller action
1%
Redirects to the homepage if the user is logged in
1
x = 5
y = 10
x, y = y, x
puts "#{x} #{y}"
The quiz will be in 1 minute
👍3❤1
array = [1, 2, 3, 4]
array.each do |num|
next if num.even?
print num
end
The quiz will be in 1 minute
x = [1, 2, 3]
y = x.map { |n| n * 2 }
x[0] = 10
puts "#{x} #{y}"
The quiz will be in 1 minute
What will be printed when the following code is executed? ☝️
Anonymous Quiz
88%
[10, 2, 3] [2, 4, 6]
3%
[10, 2, 3] [1, 2, 3]
5%
[1, 2, 3] [2, 4, 6]
5%
Error
What will be the output?☝️
Anonymous Quiz
70%
Rescued: Oops\nFrom ensure
16%
Rescued: Oops
10%
From ensure
5%
Error
👎11🤯6
👎12
Forwarded from Ruby Interview | Ruby on Rails
🤯7🤔1
What does the << operator do with strings?
Anonymous Quiz
18%
HelloWorld
71%
Hello World
10%
Error
1%
nil
How do you correctly create an empty array?
Anonymous Quiz
24%
arr = []
6%
arr = Array.new
71%
Both options
0%
nil
What is the default return value of a method in Ruby if no explicit return is used?
Anonymous Quiz
44%
nil
1%
undefined
53%
The value of the last executed expression
2%
Error
🥱5
Which of the following is NOT a valid way to define a method in Ruby?
Anonymous Quiz
2%
def my_method; end
2%
def my_method(); end
0%
def my_method(param1, param2 = 5); end
96%
function my_method() {}
🤡3🤔2
Which SQL command is used to remove all records from a table without deleting the table itself?
Anonymous Quiz
56%
TRUNCATE
35%
DELETE
6%
DROP
4%
REMOVE
🤔2💊2
What is the default sorting order in SQL if ORDER BY is used without specifying ASC or DESC?
Anonymous Quiz
19%
DESC (Descending)
62%
ASC (Ascending)
9%
Depends on the database
9%
No default order