Category: Ruby On Rails

  • Notes on the Rails 8 Keynote: “It’s More Fun to Be Competent”

    David Heinemeier Hansson is back with the the Rails World keynote talking about the trends he is seeing in the industry and where he wants to take Rails 8. As usual, the keynote has lots of interesting ideas and the next version of Rails is giving us developers lots of new tools. I want to…

  • Should I fix the terrible app I inherited? Or totally rewrite it?

    Assuming this app is larger than a one day to one week rewrite (for yourself or your team) then the question has to be asked: Do we completely rewrite this app as a new v2 or do we refactor the existing code base? Size and scope The biggest problem of an inherited app is that…

  • Stimulus Intro

    Stimulus is the Rails team JavaScript framework which intends to provide an elegant and simple solution to enhancing HTML interactivity without reaching for the complexity of a full Single Page Application (SPA). It’s meant for developers looking to augment their normal Rails, server-rendered pages with just a bit of client-side JavaScript. Stimulus is used to…

  • Link_to and Link_to_unless

    Building a navigation bar in Rails is pretty easy. You simply write up something like: And you get a set of urls for your link that look like this: However if you are on the “Docs” page already then you dont’t really need the “Docs” link to be a link. It could just be text.…

  • Using Service Objects to extract business logic.

    The Rails defaults work really well. You start with really nice, clean models and controllers. You can view them all as one page of code and hold an idea of what they do in your head. Problem is that they keep getting bigger as you add features and eventually they balloon out of control. Giant…

  • Why do we bundle exec?

    A common question I get is why do we need to prepend a command with bundle exec? Running the command by itself seems to work most of the time so what is difference? We know that rake db:migrate (for example) is the command we want to run. We know that bundle install is how you…

  • Pushing Rails validations down to the database?

    Ever open up a Rails console to debug a problem and come away wondering how the data got so funky? Despite our best efforts, the database will accept plenty of garbage data if you let it. There are tons of methods to bypass the Rails callbacks and validations while still updating your database. If you…

  • Organizing large Rails projects

    Do you have a Rails app that has gotten so big it is getting hard to know what is going on? When you have a new Rails app it is easy to tell what the app does by looking at the files in the models’ folder, but as the app gets bigger you often lose…

  • Using Rails form objects

    Update: User MelissaLiberty from Reddit pointed out how they would improve the form object and some of it faults. This post has been updated to reflect their excellent points. Often, when we start a new Rails app we start with simple controllers, and we start by generating everything with scaffolding. There is nothing wrong with…

  • Killing dead Rails controllers

    So you’ve inherited an app. It is pretty well tested and doesn’t throw too many errors but the app is big enough that it is hard to tell what is going on most of the time. The original developers are long gone and you need to build new, mission-critical features into the app but writing…