Posts for: #ruby-on-rails

Avoid polluting MVC: an opinionated Rubyist view

Avoid polluting MVC: an opinionated Rubyist view
The MVC architecture, today’s standard for at least web development, if abused, often turns into a nightmare of objects sharing a lot of responsibilities, and spanning across different areas, knowing about different objects, essentially defeating the holy grail purpose of separation of concerns. We shouldn’t be polluting MVC, we should be embracing it. There’s a reason that monolithic have become a problem, and while I certainly favor micro-services and SOA for complex applications, I’m aware that usually the problem with them it’s not having everything under the same directory structure, it’s not the team, and it’s not isolating components, it’s usually the code inside that app that has become a burden to maintain and refactor.
Read more

JWT with Rails, Sorcery and AngularJS

JWT with Rails, Sorcery and AngularJS
JWT (short for JSON Web Token) is a compact URL-safe means of representing claims to be transferred between two parties, as defined by the standard. It’s usually used for authentication and recently is being favored over the classic cookie scheme in Single Page Applications (SPAs). Although cookies and server-side authentication are the most established solutions, for APIs usually better alternatives are OAuth2 and JWT. This post assumes some level of familiarity, but should be easy to follow, visiting the homepage that I linked before should suffice for most of the code samples, if you want me to do a resources recommendation to dig deeper you can check Intridea’s blog post, another one by Toptal (it’s focused on Laravel, but the introductory section it’s worth reading), or if you want to go all the way you check this PluralSight course on OAuth2, OpenID Connect and JWT.
Read more

My Answers to… “Ruby on Rails Interview Questions: Advanced”

Every now and then, I stumble upon some post that raises interesting questions worth to be answered or commented upon, hence the “My Answers to…” series. This one in particular is worth the name since they’re explicitly relating to interview questions, which were formulated in a very interesting blog post follow-up by Sohan back in 2010. Questions 1. What is Rack Rack is a web server interface for Ruby frameworks. It provides a common interface and middleware to provide a common HTTP-to-application-server communication layer regardless of the backend server implementation.
Read more