Paperclip has_attached_file not working with Rails establish_connection
问题 I am trying to access images from paperclip using establish_connection. Here is my code of model article.rb class Article < ActiveRecord::Base if Rails.env.production? establish_connection SECONDARY_DB_CONFIG else establish_connection "article_#{Rails.env}" end has_many :assets, dependent: :destroy accepts_nested_attributes_for :assets validates_associated :assets end file asset.rb class Asset < ActiveRecord::Base if Rails.env.production? establish_connection SECONDARY_DB_CONFIG else