For a project, we wanted to write a feature spec for the mobile variant of the site. Instinctively, the first thing I did was google. I found nothing. The next thing I did was think. I came up with this, which worked:
feature 'Mobile variant' do
scenario 'Look at customer information' do
# your test here!
In order to debug a problem, which only occurred in production, we recently wanted to tweak our Rails SQL logs to only show the access to a specific table.
Here’s what we did to accomplish this. We created a file
initializers/filter_sql_log.rb with this content:
alias :old_sql :sql
if event.payload[:sql].include? 'users'
This monkey-patches the
ActiveRecord::LogSubscriber class and only delegates to the old logging method, if the SQL statement includes the string
By default, SQL logging is deactivated in the Rails production environment. Therefore we needed to change
config/environments/production.rb like this:
config.log_level = :debug