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...
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...
Use Traim to build a RESTful API for your ActiveRecord models with very little code. Traim assumes your API resources...
In the ruby shell (IRB) and rails console the return value of the previous command is saved in _ (underscore). This...
Rails 5 (don't know about the others) comes with an initializer wrap_parameters.rb. Here you can tell rails to wrap...
Put the line below in the respective env.rb file to make your action controllers raise an ActionController::UnpermittedParameters error when...
Webpack is the future. We're using it in our latest Rails applications. For tests, we want to compile assets...
Rails default config uses the ActiveSupport::Cache::NullStore and disables controller caching for all environments except production: config.action_controller.perform_caching = false...
If you use the Better Errors gem, you will sometimes notice that it can be very slow. This is because...
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...
Since Rails 5, domain models inherit from ApplicationRecord by default. This is the place to put code that should be...
Rails supports time zones, but there are several pitfalls. Most importantly because Time.now and Time.current are completely different things and...
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...
Database connections are not thread-safe. That's why ActiveRecord uses a separate database connection for each thread.
This card compares patterns to store trees in a relation database like MySQL or PostgreSQL. Implementation examples are for the...