Interview Prep Flashcards

1
Q

What standard seven restful actions for

resources :photos

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe a class, an object, a module, and why we need them?

A

Classes are constructs that create instances of themselves and enables instances to have state and behavior. Objects are instances of class. Modules are a collection of methods and constants.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the three levels of method access control for classes?

A

The three levels of access are Public, Protected, and Private.

Public methods can be called by all object and subclasses and are enforced by no access control. Protected methods are only accessible to objects within the same class. Private methods are only accessible within the same instance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does self mean?

A

Self always refers to the current object. However, classes are also objects in Ruby. A candidate that notes that should get bonus points.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe functional testing.

A

In Rails, functional testing lets you test the response of various actions contained in a controller. The programmer should understand that the functional test will tell their testing library to expect certain responses based on control requests.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Always have the programmer program.

A

Knowing textbook answers for questions is one thing. Being able to execute Ruby-On-Rails is another. You always want to set up real world tests for your candidates. For a beginner position, have the candidate perform actions such as creating and setting up a Rails environment or using migration to manage a database.

Intermediate candidates should be able to perform actions such as setting up and deploying a Rails app for production.

Experienced candidates should be able to analyze current applications for things such as performance, memory, and security issues. Additionally they should model databases and analyze queries.

There is an abundance of self-proclaimed Ruby-On-Rails experts out there. Sifting through the pros and amateurs will take time but will prove worthwhile in the end.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the naming convention in Rails?

A

Variables: For declaring Variables, all letters are lowercase, and words are separated by underscores

Class and Module: Modules and Classes uses MixedCase and have no underscore; each word starts with a uppercase letter

Database Table: The database table name should have lowercase letters and underscore between words, and all table names should be in the plural form for example invoice_items

Model: It is represented by unbroken MixedCase and always have singular with the table name

Controller: Controller class names are represented in plural form, such that OrdersController would be the controller for the order table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain what is “Yield” in Ruby on Rail?

A

A Ruby method that receives a code block invokes it by calling it with the “Yield”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Explain what is ORM (Object-Relationship-Model) in Rails?

A

ORM or Object Relationship Model in Rails indicate that your classes are mapped to the table in the database, and objects are directly mapped to the rows in the table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Mention what the difference is between false and nil in Ruby?

A

In Ruby False indicates a Boolean datatype, while Nil is not a data type, it have an object_id 4

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain what is the role of sub-directory app/controllers and app/helpers?

A

App/controllers: A web request from the user is handled by the Controller. The controller sub-directory is where Rail looks to find controller classes

App/helpers: The helper’s sub-directory holds any helper classes used to assist the view, model and controller classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is the difference between String and Symbol?

A

They both act in the same way only they differ in their behaviors which are opposite to each other. The difference lies in the object_id, memory and process tune when they are used together. Symbol belongs to the category of immutable objects whereas Strings are considered as mutable objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Explain how Symbol is different from variables?

A

Symbol is different from variables in following aspects

  • It is more like a string than variable
  • In Ruby string is mutable but a Symbol is immutable
  • Only one copy of the symbol requires to be created
  • Symbols are often used as the corresponding to enums in Ruby
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Explain what is Rails Active Record in Ruby on Rail?

A

Rails active record is the Object/Relational Mapping (ORM) layer supplied with rails. It follows the standard ORM model as

  • Table map to classes
  • Rows map to objects
  • Columns map to object attributes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

how you can create a controller for subject?

A

Command Line:

  • ruby generate controller subject
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what is Rail Migration?

A

Rail Migration enables Ruby to make changes to the database schema, making it possible to use a version control system to leave things synchronized with the actual code.

17
Q

List out what can Rail Migration do?

A

Rail Migration can do following things

  • Create table
  • Drop table
  • Rename table
  • Add column
  • Rename column
  • Change column
  • Remove column and so on
18
Q

what is the role of Rails Controller?

A

A controller can thus be thought of as a middle man between models and views. It makes the model data available to the view so it can display that data to the user, and it saves or updates data from the user to the model.

19
Q

Explain what is Cross-Site Request Forgery (CSRF) and how rails is protected against it?

A

CSRF is a form of attack where hacker submits a page request on your behalf to a different website, causing damage or revealing your sensitive data. To protect from CSRF attacks, you have to add “protect_from_forgery” to your ApplicationController. This will cause Rails to require a CSRF token to process the request. CSRF token is given as a hidden field in every form created using Rails form builders.

20
Q

Explain what is Mixin in Rails?

A

Mixin in Ruby offers an alternative to multiple inheritances, using mixin modules can be imported inside other class.

21
Q

Explain how you define Instance Variable, Global Variable and Class Variable in Ruby?

A
  • Ruby Instance variable begins with — @
  • Ruby Class variables begin with — @@
  • Ruby Global variables begin with — $
22
Q

Mention what is the difference between the Observers and Callbacks in Ruby on Rail?

A

Rails Observers: Observers is same as Callback, but it is used when method is not directly associated to object lifecycle. Also, the observer lives longer, and it can be detached or attached at any time. For example, displaying values from a model in the UI and updating model from user input.

Rails Callback: Callbacks are methods, which can be called at certain moments of an object’s life cycle for example it can be called when an object is validated, created, updated, deleted, A call back is short lived. For example, running a thread and giving a call-back that is called when thread terminates

23
Q

Explain what is rake in Rail?

A

Rake is used for normal administration tasks like migrating the database through scripts, loading a schema into the database, etc.

24
Q

The log that has to be seen to report errors in Ruby rails?

A

Rails will report errors from Apache in the log/Apache.log and errors from the Ruby code in log/development.log.

25
Q

What is the difference between redirect and render in Ruby on Rail?

A

Redirect is a method that is used to issue the error message in case the page is not issued or found to the browser. It tells browser to process and issue a new request.

Render is a method used to make the content. Render only works when the controller is being set up properly with the variables that require to be rendered.

26
Q
A