Need to practice your Ruby on Rails skills for an upcoming job interview? Try solving these Ruby on Rails interview questions that test knowledge of HTTP routing, database abstraction and migration, and other skills. We’ll provide feedback on your answers, and you can use a hint if you get stuck.
These Ruby on Rails interview questions are examples of real tasks used by employers to screen job candidates such as Ruby developers, Ruby on Rails developers, back-end developers, and others that require knowledge of the Ruby on Rails web application framework.
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.)