How To Fix The N+1 Problem

How To Fix The N+1 Problem

The N+1 Problem is one that exists in most ORMs, or Object Relational Mapper tools. The N+1 problem happens as a result of so called “lazy-loading”. Lazy loading of data from the database happens when a query is made for a parent record, and then an additional query for every single child record. In this tutorial, we’ll take a look at how to solve the N+1 problem by making use of a technique called Eager Loading.…

Configure Form and Button For A Post Request

Configure Form and Button For A Post Request

In this tutorial, we will add a button nested inside a form element so that a user can click that button and submit a post request to a specific endpoint on the server. In the last tutorial, all the legwork was completed to set up that endpoint. Now, it’s just a matter of setting up the user interface side with an html form and button element.…

How To Favorite A Model

How To Favorite A Model

It’s a pretty common feature to be able to “favorite”, or vote for something in a web application. The perfect example of this might be the website reddit, where users are able to favorite or vote for a particular link or comment. In our example application we have the idea of threads and replies, and it would be cool if a user could actually choose their favorite threads or replies.…

Sorting Threads By Number Of Replies

Sorting Threads By Number Of Replies

This tutorial will find us tackling a few different topics, however the main goal is to be able to set up sorting threads by popularity according to the number of replies each thread has. To start off, we’ll need to make some changes to the main view which displays all threads. Once we get that sorted to our liking, we can begin fleshing out the test that will be required for our new feature.…

Global Query Scopes And Pagination

Global Query Scopes And Pagination

In this tutorial, we’ll talk about Global Query Scopes and Pagination among other topics. First off, we’ll make some adjustments to the current view file that displays a single thread. Right now the content is centered in a one column style layout. We will modify this to a two column layout with the main content on the left hand side. We’ll then add a smaller right hand column, and then start adding some basic meta type information that might be helpful to the user of the application.…