# Just learn Rails (Part 2)

DevFeed: [Just learn Rails (Part 2)](<https://devfeed.tech/articles/just-learn-rails-part-2-21033.md>)

Original publisher: [Read original article](<https://jakeyesbeck.com/2015/07/19/just-learn-rails-part-2/>)

Published: 2015-07-19T12:00:00Z

Content type: opinion

Language: en

Sources: [Jake Yesbeck](<https://devfeed.tech/sources/jake-yesbeck.md>)

Topics: [Rails](<https://devfeed.tech/topics/rails.md>), [Ruby](<https://devfeed.tech/topics/ruby.md>), [Architecture & Design](<https://devfeed.tech/topics/architecture-design.md>), [mvc](<https://devfeed.tech/topics/mvc.md>), [Code](<https://devfeed.tech/topics/code.md>), [Framework](<https://devfeed.tech/topics/framework.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [framework](<https://devfeed.tech/tags/framework.md>), [mvc](<https://devfeed.tech/tags/mvc.md>), [rails](<https://devfeed.tech/tags/rails.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [ruby-on-rails](<https://devfeed.tech/tags/ruby-on-rails.md>), [scalability](<https://devfeed.tech/tags/scalability.md>)

## AI overview

This opinion article argues that Ruby on Rails can enable poor encapsulation and bad habits, especially through autoloading and ubiquitous model access. It recommends separating concerns and responsibilities to improve code comprehension and avoid scalability problems.

## Source excerpt

In a previous post I explained how "just learning Rails" is not as straight forward as the phrase portrays. Even the novice programmer who learns Ruby on Rails in a methodical progression may still run into hardship. However, this is not entirely the fault of young programmer, he or she was simply enabled into bad habits. Ruby on Rails enables the complete disregard of encapsulation. Notice how I did not say that Ruby on Rails prescribes less encapsulation, it simply enables it. This idea, much like any idea posted to the Internet, is not new. Many intelligent people have come to this same realization. One such example is the Trailblazer framework, which aims to help inject some encapsulation and abstraction mechanisms Rails is lacking. (For those interested, a book has been written to more fully explain this framework). Alright, so what am I really talking about? Ruby on Rails has certain features that make it easy to forget about encapsulation. The Autoloader A keyword that most Ruby on Rails developers rarely see on a daily basis is require. A piece of Ruby on Rails magic called autoloading greatly decreased the frequency of the require keyword in Ruby on Rails applications. This has many positive aspects for new and seasoned developers alike. But, it is not without drawbacks. One such drawback is that it makes ActiveRecord objects ubiquitous. Whenever a developer has the urge to reach into the database, regardless of the context, they are able to do so. This enables horrific code. Imagine we have a view template that we want to display a user's username and their pictures. Without any guidance, this following code could come into existence: # # Reminder, this is terrible code. Never do this. # <div> <!-- Let's just go through all the users in the database. This is a new application so we don't have that many users, it will never run into scalability issues. --> <% User.all.each do |user| %> <div class='username'> <%= user.username %> </div> <div class='pictures'