Rails: How to raise I18n translation is missing exceptions in the testing environment

As of Rails 4.1.0, there’s now a better solution than the 4 year-old answers to this question: add the following line to your config file: config.action_view.raise_on_missing_translations = true I like to set this in the test environment only, but you might also want to set it in development. I would strongly advise against setting it … Read more

How do I run a migration without starting a transaction in Rails?

There’s now a method disable_ddl_transaction! that allows this, e.g.: class AddIndexesToTablesBasedOnUsage < ActiveRecord::Migration disable_ddl_transaction! def up execute %{ CREATE INDEX CONCURRENTLY index_reservations_subscription_id ON reservations (subscription_id); } end def down execute %{DROP INDEX index_reservations_subscription_id} end end

.gemrc file specification

gem looks for a configuration file .gemrc in your home directory, although you can specify another file on the command-line if you wish (with the –config-file modifier). There are three things you can specify in the configuration file: command-line arguments to be used every time gem runs command-line options for ’’RDoc’’ (used when generating documentation) … Read more

PG::UndefinedTable: ERROR: relation “active_storage_blobs” does not exist

The active_storage_blobs table does not exist yet. You need to first run: rails active_storage:install This command will add 2 migrations for 2 tables: active_storage_attachments and active_storage_blobs. These new migrations need to be run before the migrations you have above. There is a trick for this, you can consider manually changing the timestamp in the filenames … Read more

Upgrading to Rails 6.1.6.1 causes Psych::DisallowedClass: Tried to load unspecified class: Symbol

The error occurs due to the following security update in Rails: https://discuss.rubyonrails.org/t/cve-2022-32224-possible-rce-escalation-bug-with-serialized-columns-in-active-record/81017 The Hash serializer apparently loaded data with YAML.unsafe_load, which now changed to YAML.safe_load. This new method does not handle data types such as Symbol or Time by default for security reasons. The workaround as the announcement suggests is to either migrate the serializer … Read more

Could not open library ‘vips.42’; Could not open library ‘libvips.42.dylib’

If you have this problem on your local machine.. If you have just upgraded from rails 6 to 7, and have config.load_defaults 7.0 set in config/application.rb, then your app will use vips by default. If that’s what you want, just make sure vips is installed locally. You can install it with homebrew (thanks to @timroman … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)