yarn add somepackage. You’re done right? BOOM.
It’s a common scenario. Hours of frustration and confusion culminate in a single line in your
requirements.txt. A thorny problem becomes…
Welcome to Part VI of my series on Git for beginners! In this post I’m going to show you the fundamentals of connecting a local repository to a remote one and some of the most common commands you can use to interact with a remote. This post assumes you have learnt the things I’ve covered in the previous posts in this series — and that you have a local repository like the one we’ve built over the course of this series:
If you’ve been following this series up till now, you’ve learnt quite a bit of the basic functionality of Git. However, you still haven’t encountered its most compelling use case: fixing things when they go wrong. Things can go wrong in a number of ways during software development — and things do love to go wrong. In this post, I’ll introduce some Git commands you can use to fix mistakes and, if need be, restore code to an earlier version:
Welcome to Part IV of my introductory series on Git! In this post, I’ll walk you through creating a new branch, making commits on that branch, and merging the branch back into the base. So far in this series, I’ve given you an overview of how Git works, shown you how to create a new Git repository in a new or existing directory, and helped you make your first commit in the new repo. If any of those things sound unfamiliar to you, I encourage you to read or re-read those posts before continuing with this one.
As I’ve mentioned…
In this post, I’ll walk you through committing your first files to the Git repository you created in Part II of this series. (If you need an overview of what Git is or how it works, please read Part I.) To follow along, you’ll need the empty Git repository you’ve created in Part II.
This post will cover three Git commands:
Each of these commands is very flexible and has a number of options you can choose. However, since this is a guide for beginners, I will only cover a few of them here…
In Part I of this series, I gave an overview of what Git is and how it fundamentally works. In this post, I’ll show you how to initialise a Git repository on your development machine. I won’t give a full recap of Git concepts in this post, so if that’s what you’re looking for, check out Part I. That said, I will start by reviewing the concept of a Git repository.
Anyone who’s spoken to me about the subject knows my advice to people who want to start learning to code: before you do anything else, start with Linux/UNIX command line* fundamentals**, and then learn some basic Git. Git is a complex and powerful tool for managing changes to a code base and can be daunting to learn. Even I don’t know all the intricacies. Still, you can learn the stuff you need to get by without too much trouble. There are other guides to Git out there, but a lot of them are not specifically aimed at people with little…
This was a problem that plagued me for over an hour, and none of the answers I found on Google helped. I have a Rails 6 application with a model that has one ActiveStorage attachment. I needed a scope for all models that do not have a file attached. This is the model class:
ActiveRecord conveniently includes a scope called
with_attached_file , which returns, intuitively enough, an ActiveRecord relation with all the models that have a file attached. Unfortunately, there is no corresponding
Although there were several answers on StackOverflow that purported to solve this problem, none…
We had a little bit of a challenge at InView today: how to use nested attributes in forms without necessarily creating a new record in the database for every form submission. The solution turned out to be quite simple.
At InView, we have two (relevant) models: Report and Category. A Report
has_and_belongs_to_many Categories. Each Category has one attribute:
name. Category names should be unique (although this isn’t enforced through ActiveRecord for reasons I won’t go into here). For this reason, when a report is submitted with nested attributes for its categories, the categories should not be created anew if there…
Today I ran into an interesting problem. I needed to scope a Rails model by checking whether it had a child with a certain attribute. The solution was simple but a little hard to find online, so I thought I’d share.
I started out with two models:
Application. Every applicant
has_one application, and every application has a status. I want to create an
:active scope for the
Applicant class, in order to list only applicants whose application status is
"in review". Here are the models.
It turned out creating the scope was simple. All I had…
Senior Engineer at Envato