Ruby on Rails Interview Questions
Want to become an expert in cracking Ruby on Rails interview questions?
Start with practicing the questions below. Whether a question involves multiple choice or live coding, we will give you hints as you go and tell you if your answers are correct or incorrect.
After that, take our timed public Ruby on Rails Interview Questions Test.
To use our service for testing candidates, buy a pack of candidates.
1. Contacts Migration
Select all statements that are correct after the following migration has been executed:
class ContactsMigration < ActiveRecord::Migration
def change
create_table :contacts do |t|
t.string :name
t.integer :telephone_number
t.text :address, null: false
t.timestamps
end
end
end
(Select all acceptable answers.)
2. Employee Search
A company database contains the following table, in which id is the primary key:
employees
id | name | age |
---|---|---|
1 | Steve | 21 |
2 | John | 44 |
3 | Amy | 26 |
4 | Marcus | 44 |
Select all the statements that return only the employee with name "John" (id = 2).
(Select all acceptable answers.)
3. Record Route
Consider the following controller and view definitions:
class RecordsController < ApplicationController
def update
@record = Record.find(params[:id])
@record.update(record_params)
end
end
<%= form_for @record do |f| %>
<%= render 'form', f: f %>
<% end %>
Select the statements that can be used to update a record.
(Select all acceptable answers.)
- Ruby on Rails Online Test (Easy)