I'm currently doing the following which works but is inefficient since it's calling it before every action
class ApplicationController < ActionController::Base
before_action :set_intervalstyle
private
def set_intervalstyle
ActiveRecord::Base.connection.exec_query("SET intervalstyle = iso_8601", "SCHEMA")
end
end
I noticed here that they're registering this command per connection
alias_method :configure_connection_without_interval, :configure_connection
define_method :configure_connection do
configure_connection_without_interval
execute('SET intervalstyle = iso_8601', 'SCHEMA')
end
Could someone help me figure out how to convert my before_action into something like this? Maybe as an initializer? I'm not sure where to start
require 'active_record/connection_adapters/postgresql_adapter' class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter def configure_connection execute('SET intervalstyle = iso_8601', 'SCHEMA') end end