├── .gitignore └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ruby/Rails Interview Questions 2 | 3 | A collection of interview questions about Ruby/Rails. 4 | 5 | There is a reason why there are no answers here — you as an interviewee should do your own research about things you don't know or fully understand. Self-study is the best way to learn but it doesn't mean you're on your own, feel free to drop by `#ruby` or `#rubyonrails` on [Freenode](https://freenode.net) and ask questions. 6 | 7 | # Ruby 8 | 9 | - Compare `Symbol` and `String`, why use one vs the other? 10 | - Describe multiple ways to define an _instance method_ in Ruby; now do the similar for _class methods_ 11 | - Which is generally the better option (not only for Ruby): a _recursive_ function or an _iterative_ one? 12 | - What are `#method_missing` and `#send`? Why are they useful? 13 | - What are the various Ruby runtimes, and how are they different? 14 | - What does `self` mean when used in a class? 15 | - What does it mean that _"everything in Ruby is an object"_? 16 | - What is a `Hash`? How efficient is reading/writing/iterating over one? 17 | - What is a `block`? Write a method that takes a `block` as an argument 18 | - What is the difference between a `lambda`, a `block` and a `proc`? 19 | - What about _closures_ in Ruby? What are they? 20 | - Explain what `a ||= b` means 21 | - What is **memoization**? Why and when would you use it? 22 | - Have you heard the term **PORO**? Do you know what it is? 23 | - Is it bad to rescue `Exception`? Why? 24 | - What's the difference between the `&` and `&&` operators? 25 | - What's the difference between the `and` and `&&` operators? Why use one over the other? 26 | - What is **meta-programming**, what methods of **meta-programming** does Ruby support, and when/why would you use it in a project? 27 | - What does the `lazy` method do to enumerators and why is that useful? 28 | - Why do some methods end with a bang `!` and others with question marks `?`, what are they called and what do they do? 29 | - Go through Basic OOP primitives like _encapsulation_, _abstraction_, _polymorphism_ and _inheritance_ 30 | - Talk about **SOLID** principle 31 | - What's the difference between `extend`, `prepend`, and `include`? 32 | - Describe access modifiers and how they are used within the ruby language (`private`, `public`, `protected`) 33 | - How would you declare and use a _constructor_ in Ruby? 34 | - How would you create _getter_ and _setter_ methods in Ruby? 35 | - What is a `Class`, what is an `Object` and why we need `Module`? 36 | - Does Ruby support _multiple inheritance_? 37 | - What are **mixins**, how do they work, and how would you use them? What are some advantages of using them and what are some potential problems? Give examples to support your answers 38 | - Explain what singleton methods are, what is _Eigenclass_ in Ruby? 39 | - Describe Ruby method lookup path 40 | - Describe available Ruby callbacks and how can we use them in practice? 41 | - Why `Enumerable` is so useful? Elaborate on methods like `.each`, `.map`, `.inject`, `.reject`, _et cetera_ (also shortcut notation e.g. `.reduce(:+)`) 42 | - Why would you use `BigDecimal` over `float`? 43 | - When do you prefer to use `fetch` over `[]` on `Hash` (and other way around) and why? 44 | - What's the difference between `local`, `@instance`, `@@class`, and `$global` variables? Why and where would you use specific type? 45 | - How can you implement method overloading? 46 | - How can you call the _base class method_ from inside of its _overriden method_? 47 | 48 | # Rails 49 | 50 | - Explain the different pieces of Rails 51 | - Explain the processing flow of a Rails request 52 | - Explain **MVC** in terms of Rails 53 | - What is **REST**? 54 | - Describe the Rails Asset Pipeline and how it handles assets (such as JavaScript and CSS files); bonus points for explaining what was the big change in Rails 5.1 55 | - What is an **ORM**? 56 | - What is ActiveRecord and what is Arel? Describe the capabilities of each 57 | - What is the **Convention over Configuration** pattern? Provide examples of how it is applied in Rails 58 | - What is the _fat model, skinny controller_ approach? Discuss some of its advantages and pitfalls, as well as some alternatives 59 | - Describe the Rails testing philosophy 60 | - What is the purpose of layouts? 61 | - Explain the use of `yield` and `content_for` in layouts and provide examples 62 | - What are `N+1` queries and how can you avoid them? How would you find/debug `N+1` queries? 63 | - What are filters/actions in Rails? Describe the three types of filters, including how and why each might be used, and the order in which they are executed 64 | - What is Rack middleware? How does it compare to controller filters/actions? 65 | - Explain what Rails' mass-assignment vulnerability is and Rails' method to control field access 66 | - How do you sort an `Array` of objects by a particular attribute? What is a better way to do sorting with ActiveRecord? 67 | - What are the different server options for running a Rails/Rack app? 68 | - Explain **CSRF** and how Rails combats it 69 | - Explain various forms of caching available in Rails 70 | - How is something like `30.seconds.ago` implemented? 71 | - What is Rails _concern_? 72 | - What is functionality of _helpers_? 73 | - Which Rails server are you using? 74 | - Which HTML template engine does Rails support? 75 | - What are some ActiveRecords callbacks which you are familiar with? 76 | - Does ActiveRecord have `after_delete` callback? 77 | - What are the benefits of using active records as opposed to native SQL queries. On which occasion should you be choosing one over the other? 78 | - Explain `rails db:migrate` and the benefits that comes along with that? 79 | - Explain how Rails' scaffolding works and why you would want to use them 80 | - What is _database transactions_ and how it is represented in Rails? 81 | - Explain ActiveRecord's associations (all of them) 82 | - What are scopes in ActiveRecord? How should you use them? 83 | - Where would you use `#pluck` and why exactly is it useful? 84 | - Explain _eager loading_ 85 | - How can you eager load associated objects? 86 | - What is difference between `render` and `redirect`? 87 | - What is difference between `save!` and `save`? (Elaborate on general difference between AR methods with and without a bang `!`) 88 | - What is difference between `form_for` and `form_tag`? 89 | - What is the purpose of `environment.rb` and `application.rb` files? 90 | - What is `request.xhr`? 91 | - How can you list all routes for a Rails application? 92 | - Give an example of nested routes usage 93 | - What is _observer_ in Rails? 94 | - What deployment tools do you use? 95 | - Why do some people say _"Rails can't scale"_? 96 | - When is Rails a good choice for a project? 97 | - What are some of the drawbacks of Rails? 98 | 99 | # Meta 100 | 101 | Topics below require general Computer Science knowledge that is not tightly coupled with any _specific_ technology stack hence the more you know the better you'll be. 102 | 103 | - Algorithms and Data Structures 104 | - Database Design, SQL queries, NoSQL databases 105 | - Testing (TDD/BDD) 106 | - System Design 107 | - DevOps 108 | - Unix knowledge 109 | - Networking 110 | - Application Security 111 | 112 | [Cracking the Coding Interview](https://www.amazon.com/Cracking-Coding-Interview-Programming-Questions/dp/0984782850/) is a good resource for high level overview. 113 | 114 | # References 115 | 116 | - https://www.toptal.com/ruby-on-rails#hiring-guide 117 | - https://www.toptal.com/ruby/interview-questions 118 | - https://www.quora.com/How-do-I-prepare-for-an-entry-level-Ruby-on-Rails-developer-interview-What-questions-should-I-expect 119 | - https://github.com/afeld/rails_interview_questions 120 | - https://github.com/rishiip/ruby-on-rails-interview-questions 121 | - https://gist.github.com/ryansobol/5252653 122 | - http://www.rubyinside.com/tips-hiring-ruby-web-developers-4757.HTML 123 | - https://rubygarage.org/blog/how-to-interview-your-ruby-on-rails-developer 124 | - http://anilpunjabi.tumblr.com/post/25948339235/ruby-and-rails-interview-questions-and-answers 125 | - http://career.guru99.com/top-34-ruby-on-rail-interview-questions/ 126 | - http://blog.mypath.io/ruby-on-rails-interview-questions-that-will-land-you-the-job/ 127 | - https://srikantmahapatra.wordpress.com/2013/11/07/ruby-on-rails-interview-questions-and-answers/ 128 | - https://www.codementor.io/ruby-on-rails/tutorial/ruby-on-rails-interview-questions 129 | - http://www.careerride.com/ruby-on-rails-interview-questions.aspx 130 | 131 | # Contributing 132 | 133 | Contributions are welcome. If you would like to correct an error or add new items to the checklist, feel free to create an issue and/or a PR. If you are interested in contributing regularly, drop me a line at the above e-mail to become a collaborator. 134 | --------------------------------------------------------------------------------