makandra dev

ActiveSupport::Dependencies takes care of auto-loading any classes in development. This is usually useful, but when you run into...

This is an extension to PostgreSQL vs MySQL: How to UPDATE using a JOIN. UPDATE employees SET department_name = departments.name...

TL;DR Use user.update!(remove_avatar: true) to delete attachments outside of forms. This will have the same behavior as...

This is a small example on how you can check if your Postgres index can be used by a specific...

github.com

The issue: You are using stub_const to change a constant value for your test. stub_const "SomeClass::CONST", 'test...

blog.bigbinary.com

This error is raised because your old database does not have a configured environment yet, which Rails 5 enforces.

makandra dev
makandracards.com

Rails applications and ruby gems should have a README that gives the reader a quick overview of the project. Its...

You should avoid using application models in your migrations. But how else could you create records in a migration?

postgresql.org

PostgreSQL's Common Table Expressions (CTEs) can be used to extract sub-queries from bulky SQL statements into a temporary...

PostgreSQL supports the SQL OVERLAPS operator. You can use it to test if two date ranges overlap: => SELECT ('2001-02...

relishapp.com

In most projects I know, Cucumber test suite speed is not an issue. Of course, running 350 features takes its...

github.com

When you're using Sidekiq::Web to monitor the Sidekiq status AND have your session cookie configured to a wildcard...

When attempting to update RubyGems, depending on updates your previously performed, you might run into an error ERROR: While executing...

We're usually running Ubuntu LTS versions. Sometimes newer hardware requires packages from more recent Ubuntu releases that only come...

A common pattern in Ruby is to to require all files in a specific diretory, using something like Dir.glob(Rails.root.join...

makandra dev

An end-to-end test (E2E test) is a script that remote-controls a web browser with tools like Selenium...

Browsers support different types of redirects. Be very careful with these status codes: 301 Moved Permanently 308 Permanent Redirect

When you want to group rails models of a logical context, namespaces are your friend. However, if you have a...

Let's say you have a form that you render a few times but you would like to customize your...

After loading a staging dump into development, you might get an ActiveRecord::EnvironmentMismatchError when trying to replace the database (like...

When localizing model attributes via I18n you may run into errors like this: I18n::InvalidPluralizationData: translation data {...

...} can not be...

If another session is accessing your database you are trying to reset or drop you might have seen the following...

docs.ruby-lang.org

Use return to return from a method. return accepts a value that will be the return value of the...

I frequently find myself needing a combination of group_by, count and sort for quick statistics. Here's a method...