Cover image for Learning Rails: Concepts To Know Before Starting

Learning Rails: Concepts To Know Before Starting

_morgan_adams_ profile image morgana Originally published at morgandadams.com on ・4 min read

Me Learning Rails

Learning Ruby on Rails has been a fun adventure so far. Yesterday, I finished the Getting Started with Rails guide on rubyonrails.org which teaches how to build a simple blog app. Surprisingly, it does a thorough job of covering a number of features from working with the MVC to setting up routes and basic authentication.

I often hear that Ruby on Rails has a high learning curve – I want to dispute that. After finishing the guide, I feel confident I can start building my own apps using Rails and I think others can as well.

Key Concepts to Learn to Understand Rails

Admittedly, if you know a few things before diving into Rails, it will make a lot more sense. I plan to cover some of those things here in this post. They are:

  1. Model View Controller (MVC) design pattern
  2. Web frameworks
  3. Convention over Configuration

If you are already familiar with these concepts, go ahead and jump into the Getting Started with Rails guide.

*Note : You don’t need a lot of Ruby knowledge to start, although it certainly helps. Just having some basic-intermediate level programming experience in general would be a good start. With the heavy emphasis on convention, you don’t need much code to get functioning CRUD operations and relations.

** Disclaimer : I’ve primarily been working in Operations, Site Reliability Engineering, and Security. So if my language isn’t precise on some of this, feel free drop me a note so I can correct it.

Model View Controller

First, lets look at MVC.

MVC is a common design pattern for the web. Although, you can see MVC in non-web applications it (and similar patterns) seems to be fairly ubiquitous around the web.

I won’t dive into a lot of MVC details since there exists an abundance of documentation on the subject, but I’ll cover some highlights.

Models are literally the object or idea you are trying to represent: an article, a search result, a goblin, a customer, etc.

Views are how you present information – specifically from the models. This often appears in the form of templates.

Controllers are the glue that tie models and views together. They take user requests, manipulate or retrieve models, and then render a view. In Rails, routes or URL paths map to controllers.

There is certainly plenty more on the subject and I encourage you to dig in more. Here are a few MVC articles to start:

Web Frameworks

If you think about what goes into building a web application, there are several common elements. Some of these are authentication, MVC, connecting to databases, input validation, and URL mapping – Wikipedia covers and links to more details [link]. Rails is such a framework and has a lot of these features readily available to help you focus on the business logic.

Because so much is implemented for you, you don’t always know the implementation details. That’s okay. Read the docs and play around with code examples. The behavior becomes apparent quickly.

Rails uses convention to conveniently tie the MVC part of the framework together. It might take a bit of getting used to it, but it’s achievable.

Convention Over Configuration

Rails focuses on Convention over Configuration. Although it might obscure some implementation details, it means less lengthy configs.

Previously, I worked in setups where there are literally hundreds of config files. Ultimately, you end up with config files with outdated options and a new source of tribal knowledge.

For example, the Getting Started guide you run a command to create your model. This also produces a db migration file. After running the migration, you will have a table whose name is the plural of the model. Additionally, it’ll do all the mapping between model and table attributes (Object Relational Mapping). In the end, convention saves you a lot of setup.

The Rails folks cover Convention over Configuration philosophy really well [link].

Getting Started With Rails

So now you know a little behind some of the key ideas behind Rails. Go follow their guide. It’s lengthy but it takes you from installation to a working app.

screenshot of blog app

Screenshot of the blog app

When you finish, you will have worked with the MVC, routes, security, authentication, and a database. It’s just shallow enough to cover the important highlights and detailed enough to see how powerful it can be. Happy coding!

*NOTE : On the installation, you’ll need to install a few extra dependencies: nodejs, yarn, ruby-dev, build tools, and libz-dev.

The post Learning Rails: Concepts To Know Before Starting appeared first on Morgan Adams.

Posted on by:

_morgan_adams_ profile



Building and securing all the things. Python is my goto. I'm a software eng by trade, background in SRE/Ops roles, and enjoy security.


Editor guide

I agree with you, maybe need learn about testing. Because rails is very powerful for write test