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

requestb.in

Requestb.in is a webservice that gives you a temporary URL you can use to test request. The page will automatically...

Checking if a JavaScript value is of a given type can be very confusing: There are two operators typeof and...

github.com

When an Rspec example fails, I usually investigate by running that example again using rspec . However, this does not work...

When your public-facing application has a longer downtime for server maintenance or long migrations, it's nice to setup...

You need to set the :inverse_of option manually for relations that have an association to a polymorphic model. Otherwise...

RSpec allows defining methods inside describe/context blocks which will only exist inside them. However, classes (or any constants, for that...

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

github.com

FactoryBot allows a :class option to its factory definitions, to set the class to construct. However, this option is not...

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

Sometimes you add Paperclip image styles, sometimes you remove some. In order to only keep the files you actually need...

ActiveRecord::RecordNotFound errors provide quite meaningful error messages that can provide some insight on application details. Consider the following:

I needed to make sure that an element is visible and not overshadowed by an element that has a higher...

When using GROUP BY, MySQL now complains if the SELECT includes columns which are not part of the GROUP BY...

Nowadays it is fairly easy to intercept and modify mails globally before they are sent. All you have to do...

By default Middleman generates files with a .html extension. Because of this all your URLs end in /foo.html instead of...

Middleman is a static page generator that brings many of the goodies that Rails developers are used to.

Dump this method into your Ruby console to quickly print data in columns. This is helpful for e.g. comparing attributes...

makandra dev
stackoverflow.com

Assuming you're wanting to undo the effects of git rm or rm followed by git add -A or something...

makandra dev

This card compares patterns to store trees in a relation database like MySQL or PostgreSQL. Implementation examples are for the...

When you load a dump for development, records may reference images that are not available on your machine.

makandra dev

Using VCR to record communication with remote APIs is a great way to stub requests in tests. However, you may...

Add the following to /etc/rc.local: (sleep 3 && echo disable > /proc/acpi/ibm/bluetooth)& Bluetooth icon will be active for a few seconds, then...

If you have a replication error with MySQL and you know the "error" is okay (e.g. you've executed the...