slal
slal

Reputation: 2867

Access a variable in Railtie initializer from other class

I have a gem which has the following Railtie class. I am trying to access my_config variable from outside, i.e another ruby class in the same gem. How can I access it?

module myModule
    module Rails
      class Railtie < ::Rails::Railtie

        initializer 'load_config' do
          my_config = "random config here"
          puts my_config
        end
      end
    end
  end
end

Upvotes: 0

Views: 88

Answers (1)

Thanh
Thanh

Reputation: 8604

Maybe you can use instance_variable_get:

myModule::Rails::Railtie.new.instance_variable_get(:@my_config)

Upvotes: 1

Related Questions