Tag: Ruby on Rails

  • Using Font Awesome 6 in a Rails 7 project that uses importmaps

    Using Font Awesome 6 in a Rails 7 project that uses importmaps

    I just figured out how to use Font Awesome 6 in a Rails 7 project that uses importmaps. I’m not entirely sure why this works and why some of the workarounds are needed, but my googling yielded no results when I was searching so hopefully here I’ll be saving the next person some time. If…

  • How I’m testing seed data generation

    How I’m testing seed data generation

    When I create a new Rails project I like to have a robust seeds that can be used to quickly bootstrap development, testing and staging environments to interact with the application. I think this is critical for development speed. If a developer creates a feature to, for example, connect two records together, you just want…

  • Nicer printing of Rails models

    Nicer printing of Rails models

    I like my models to be printed nicely, to make the class of the model as well as the id and other data available, so, when they end up in a log or console, I can now exactly what it is. I’ve been doing this since before Rails 3 and since Rails projects now have…

  • Editing Rails 6.0 credentials on Windows

    Editing Rails 6.0 credentials on Windows

    Rails 6 shipped with a very nice feature to keep encrypted credentials on the repo but separate them by environment, so you can have the credentials for development, staging and production, encrypted with different keys, that you keep safe at different levels. For example, you might give the development key to all developers, but the…

  • The Highlander query with Rails’ ActiveRecord

    The Highlander query with Rails’ ActiveRecord

    For those cases in which there can be one and only one record on the database with certain fields and I don’t just want to get the first one and silently get the wrong one. I want to make sure there’s one and only one, so, I wrote this little extension to ActiveRecord that does…

  • Avoiding threads of emails when developing a Rails application

    Call to Buzz, like many applications I developed before, sends emails. Lot’s of emails. To avoid accidentally emailing a customer or random person I use mail_safe. It’s one of the first gems I install on a Rails project and you should too. mail_safe re-writes the to-header so you end up receiving all the emails that…

  • Displaying Delayed::Job’s jobs in Active Admin

    I’ve been using both Active Admin and Delayed::Job for years now and both have served me very well. It’s very common for me to want to display job records in the admin tool and have some extra tools around them such as: the ability to mark them all for re-run the ability to run one…

  • Nicer warning dialogs with Rails and Bootstrap

    Ruby on Rails has a very convenient way of presenting a dialog for potentially dangerous tasks that require some confirmation before proceeding. All you have to do is add A problem with those, though, is that most (all?) browsers make the dialogs quite ugly: For Call to Buzz, I wanted to finally have something better.…

  • Left grouping label with Simple Form and Bootstrap 3

    If you are using Simple Form and Bootstrap 3, you probably initialized your app with something similar to: which adds a file called simple_form_bootstrap.rb to your application with many customizations that make Simple Form output nicely formatted Bootstrap 3 forms. For Call to Buzz, an app I’m building, I had several booleans to display, like this: My…

  • Storing SMTP credentials in secrets.yml in a Ruby on Rails Application

    Storing SMTP credentials in secrets.yml in a Ruby on Rails Application

    Rails 4.1 introduced the concept of secrets.yml, a file in which you store all the credentials for your app, separated by environment, so for example, development can talk to Test Stripe and production to Live Stripe. Furthermore, this file is capable of picking up environment variables which allows you to divorce credentials from code. Not properly…