makandra dev

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

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 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...

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...

before(:all) runs the block once before all of the examples. before(:each) runs the block once before each...

There are many approaches out there how you can import data from a legacy application to a new application. Here...

github.com

Use Traim to build a RESTful API for your ActiveRecord models with very little code. Traim assumes your API resources...

makandra dev

In the ruby shell (IRB) and rails console the return value of the previous command is saved in _ (underscore). This...

api.rubyonrails.org

Rails 5 (don't know about the others) comes with an initializer wrap_parameters.rb. Here you can tell rails to wrap...