ActiveRecord Anonymous Class

27 views
Skip to first unread message

Jonathan Schober

unread,
Jan 12, 2017, 1:56:47 AM1/12/17
to Ruby on Rails: Talk

As stated in #8934, using Anonymous Classes are not supported. That said, IF I were to use an anonymous class, what suggestions and concerns would you have? This is how I am using it currently

tempConnection = Class::new(ActiveRecord::Base) do
    def self.name
       @name
    end
end
tempConnection.instance_variable_set("@name","#{params[:database]}#{params[:table]}")
config = tempConnection.connection_config.clone
config[:database] = params[:database]
tempConnection.table_name = params[:table]
tempConnection.establish_connection(config)
Reply all
Reply to author
Forward
0 new messages