Ruby On Rails preguntas y respuestas de entrevista
Pregunta 66. Describe the difference between class and instance variables?
Class variables are created with the prefix ‘@@’ and are shared by all objects in a class.
Instance variables are created with the prefix ‘@’ and belong to a single object within a class.
Pregunta 67. Example some of the looping structures available in Ruby?
For loop, While loop, Until Loop.
Pregunta 68. Explain the difference between a has_one and belongs_to association in Ruby on Rails.
A product has_one provider, a customer has_one order.
Pregunta 69. Explain a polymorphic association in Ruby on Rails.
Polymorphic associations allow a model to belong to more than one other model through a single association.
- Here, the class Picture belongs_to both Employee and Product, but does so through a single association rather than through multiple.
- Be sure to know an appropriate situation to create a polymorphic association, such as creating a comment model associated with multiple other models (articles, photos, etc.). The advantage of using polymorphism here is that it allows you to create a single comment model, rather than separate models for each one (PhotoComment model, ArticleComment model, etc.)
Pregunta 70. What is a Proc?
Procs, short for procedures, act similar to blocks, but can be saved as variables and reused. Think of them as blocks you can call over and over again on multiple arrays.
Lo mas util segun los usuarios:
- What is Ruby On Rails?
- Why Ruby on Rails?
- Explain how (almost) everything is an object in Ruby.
- What are Gems and which are some of your favorites?
- How would you declare and use a constructor in Ruby?