Using Transactions with Active Record
March 06, 2015A transaction is a database feature where you can create, update, or delete multiple records from a database and if just one of them fails…
Written by Charlie Massry who lives and works in New York building useful things. You should follow him on Twitter
A transaction is a database feature where you can create, update, or delete multiple records from a database and if just one of them fails…
When dealing with the Model-View-Controller pattern, one of the problems you will face is that it is stateless, while the application itself…
When you use the Model-View-Controller pattern with Rails, you can be dragged into a state of only making models for your ActiveRecord…
If you have fallen in love with Ruby’s support for metaprogramming like I did, but want to get into iOS development, fear not as there is…
In iOS, you may want to create a bottom tab bar navigation as seen in any app where the type of interface varies differently, for example in…
In this post, we will be building an app that retrieves a collection from the web and view it as a table. The data is an index of my blog…
“There are only two hard things in Computer Science: cache invalidation, naming things, and off-by-one errors.” Fortunately for us, Rails…
Over on the left, you see that there is a nice little search box to search through my posts. When you search for something you might notice…
If you have an iPhone, and want to be able to make apps for it, you might want to consider learning Objective C. For iPhone development, you…
Coming from Ruby, Javascript can be quite intimidating for a couple of reasons, mainly focused on the object system that it implements…
At any point in time, you can run into an error in your Rails App, but don’t worry as debugging can be easy with the help of multiple gems…
Counter caching is a technique to reduce the number or SQL queries when attempting to call count on a resources’ association. For example…
In Ruby, you can extend the language significantly to suit your preferences, and even overide methods already used by the language itself…
Monkey Patching is a term in Object-Oriented Programming when you open up an existing class and add new methods to it. A good way to find…
The popular social media website Twitter has made features such as tagging through their system of hashtags very intuitive and fun. You can…
Oftentimes as Rails developers, we will run into a situation where we are making something polymorphic, and we won’t want to make any more…
Ruby has very powerful support for metaprogramming, which is also known as code that writes code, but it can be difficult to understand what…
ActiveRecord is fantastic, but sometimes if you are doing complex joins and such, you may need to move away from ActiveRecord and write raw…
When creating an Rails App using TDD, sometimes you will come across the need for an external service, for example, using the Google Maps…
Using Devise in Ruby on Rails can be very convenient for authentication, but there are some necessary workarounds that you must be aware of…
With most web apps, you’ll want to have some type of authentication system so your users’ data is secure. The question then shifts of how to…
Sublime Text is a very popular editor, but you must use your mouse at times, which takes some time away from your hands being at the…
For a website that has search functionality, you might want to have autocompletion, so when the user starts typing it automatically pops up…
Previously, I had blogged about how to set up your website to make requests to match string addresses to latitude and longitude coordinates…
In this day in age, 2014, websites using location services are becoming more and more common to better serve customers as they can provide a…
Recently, I have started looking into AngularJS, a popular front-end Javascript MVC, to help me write cleaner, better, front-end code…
In PostgreSQL version 9.2, JSON storage functionality was introduced, so now it has the capability to be schema-less. From the outside…
In Ruby on Rails, ActionMailer allows you to email users from your server with processed Ruby code, which can serve any number of uses…
There are a couple of ways to let your users nest comments with Active Record. The main issue is the comments must start from somewhere…
Recently I’ve been working on a project that allows users to upload photos or videos with the twist of using the same form and determining…
For any given web application, you probably want your users to be able to embed pictures or other types of multimedia for a richer…
The Null Object Pattern is a popular software pattern that can be very useful as it can get rid of many nil checks in Ruby. Throughout your…
In Ruby on Rails, when you want to make a particular route that has a parameter with spaces in it, you would typically get something like…
The Enumerable module can be used for all of your Ruby classes as long as they implement their own each method. A good example of this are…
The N + 1 query problem can be very tricky to deal with or even find because you won’t be typically dealing with a lot of data in…
The Enumerable module in Ruby can be used for arrays and hashes and can save you from writing complex, nested if statements and loops. all…
The Javascript syntax is not nearly as fun as Ruby’s but you must use it if you want to do anything dynamic on the client-side. Fortunately…
That’s right, polymorphic controllers in Ruby on Rails. You made your model polymorphic, but now you would have to make a controller for…
I have heard of a polymorphic relationship before, and it was difficult to wrap my head around but it is actually very simple, as it has…
When creating a self referential join through another table, you must think of each entry as a new row even if two of the columns have the…
If you want to create vanity URLs, and who doesn’t, then to_param is the method for you. In fact it is my personal favorite method in Ruby…
At Metis, we haven’t been using test driven development to help develop our Ruby on Rails apps. Instead of learning TDD, we’ve been using…
In Ruby, there is a huge community of packages, a lot of which interact with Ruby on Rails. These are called Gems, and they are hosted at…
In SQL, you can’t have two tables that have each other’s foreign key, you must use a third table to hold the foreign keys of the…
If you want to have user authentication on Rails, but don’t require something as hard hitting as Devise or Clearance, Monban is the way to…
In every Internet Browser, there are what are called cookies. These are a way of overriding the fact that HTTP is a stateless protocol…
One of the founding principles of Ruby on Rails is “Don’t Repeat Yourself”, or DRY. There are many reasons to follow this principle, not the…
There are a few key things you must remember when working with nested resources in Ruby on Rails. The first thing to do is edit your routes…
Ruby on Rails follows the popular Model, View, Controller paradigm. One thing of note about this is Rails’s separation of the routes from…
During the first week of Metis, we were tasked to build a flash card game playable from the command line. We kept adding features, and what…
In HTTP, there are four common request actions that are used by servers, GET, POST, PUT, and DELETE. This maps to CRUD, Create, Read, Update…
Active Record is the preferred method of interacting with a database. Being a Ruby Gem independent of Ruby on Rails, Active Record can work…
This line of advice should always come in handy when working with Sinatra. We learned about the popular Domain Specific Language, Sinatra…
Writing in SQL can be daunting at first, but the more you practice the more it seems like it’s its own programming language. For example…
I used to think that this statement would evaluate to true, until very recently, which is the reason for this blog post, and hopefully this…
In Ruby, Hashes are a very powerful class that can store a key value pair. This is very useful if you need to create a database as you make…
I have updated the site with SASS which has greatly cleaned up my CSS code and you should use it too. When I first started designing the…
I built this blog to showcase problems, solutions and thoughts about web development, web design and technology. That being said I did run…