Routing Concerns in Rails You must have used concerns in Rails. Did you know you can also use concerns for your routes? They allow you to declare common routes to be reused in other resources and routes. This post covers the basics of routing concerns, including what they are, how they work, and when you might need them.
How to Count the Number of Commits After a Specific Commit in Git Counting the number of commits after a specific commit in Git is a common task when you make small but frequent commits and need to squash them before rebasing from the main branch. This post shows one simple way to do this in git. Let me know if you know a better solution.
The Rails Router Handbook For the past few days, I've been trying to learn everything I could about the Rails router. I compiled all of my notes together with the past articles on this blog, and published a handbook on the router. I hope you find it useful and you learn a thing or two about the incredible Rails Router.
How to Access Raw POST Data in Rails This post shows how you can access the raw, unaltered request body using a 20-year old method in the Rails framework (from the founder of Shopify). The `raw_post` method reads the request body, and is useful for web services or API controllers that need to directly work with raw requests.
Polymorphic Associations in Rails: Why, What, and How Polymorphic associations in Rails allow a single model to belong to multiple models. This article covers them in-depth. We'll start with understanding the concept of polymorphism, learn what a polymorphic association is, why we need them, how they work, and how to use them in your Rails application.
My Notes from Shape Up: Shipping Work that Matters This post contains my notes and highlights from the Shape Up from 37signals. It contains practical and actionable advice on project management, planning, and actually shipping meaningful work. I found it a great alternative to traditional practices like Agile. Give it a try on your next project!
How to Setup Rails-like Integration Tests in Ruby In this next post in the Rails Companion series, we'll add support for integration testing to our Ruby web application. Specifically, we'll set up the Minitest framework and simulate HTTP requests using the rack-test gem. Finally, we'll add some syntactic sugar to make our tests just like Rails.
How to Access Rails Models in a Rake Task This article shows how you can access your application models and other constants inside rake tasks by adding the `environment` task as a dependency. We'll also go one level deeper and learn exactly how this task loads the environment by inspecting the Rails source code.
Understanding Rails Parameters Rails parameters let you access data sent by the browser, either in the URL or via form submission. In this article, we'll cover the basics of parameters, including what they are, how they work, and why they're important. We'll also learn how you can pass parameters when redirecting a request.
Working with Resourceful Routes in Ruby on Rails The concept of resourceful routing took me a long time to understand, but once it clicked, it changed how I viewed web applications. This post covers the basics: what a resource is, the routes it generates and how resourceful routing provides a nice organizational structure your Rails applications.
I am Available as a Freelance Developer With my current projects wrapping up, I have the capacity to take on at least one or two new freelance projects, and I can devote my full attention for 20-30 hours each week per project. If you (or your team) are looking for a freelance Ruby and Rails developer, please reach out to me via email.
How to Route an Incoming URL to a Rack Application in Rails The Rails router can dispatch an HTTP request to a Rack endpoint, either in your application or within a gem. This is useful when you want to provide a well-isolated web UI or front-end to the users of your gem. In this post, we'll learn why you may want to do this, how it works, and how to do it.