Tag: Ruby

  • Creating blog posts in WordPress.com programatically

    Creating blog posts in WordPress.com programatically

    One of my projects, Unbreach, has a database of more than 600 breaches. These come from haveibeenpwned and they are composed of some metadata, a one-paragraph description, and an image. I wanted to improve these with more content, links to articles, tweets, videos, and some content of my own. I decided that a good way […]

  • 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 […]

  • 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 […]

  • Show a devise log in or sign up forms in another page

    This is an update of an old post of similar name but for a newer version of Devise and with better design decisions. The old post was for Devise 1.0.8, this one covers 4.0.0 I was trying to have a single page with both sign in and sign up forms with Devise 4.0.0 but this […]

  • Run bundler-audit during testing

    Run bundler-audit during testing

    There’s a gem called bundler-audit that checks whether any of the gems in your project have open security advisors against them. A year or so ago there was an infamous month in which Rails itself got three of those. It was terrible and I think bundler-audit is a good idea. My only problem with it […]