B
B
Bogdan2017-05-26 18:00:53
Ruby on Rails
Bogdan, 2017-05-26 18:00:53

How to properly use and store global constants in Rails?

Hello! As though lamersky a question, do not judge too harshly. Now I declare and use global constants in
app/controllers/application_controller.rb

$ghSavon = { wsdl: Rails.env.production? ?
    'http://192.168.1.2:8080/gos_release/ws/createsd.1cws?wsdl' :
    'http://192.168.1.2:8080/Gos1_New/ws/Integration/?wsdl',
      namespaces: { 'xmlns:ins0' => 'http://www.reality.sh' } }

But how would I think that there is a better solution? Maybe in a config file?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
Zaporozhchenko Oleg, 2017-05-26
@c3gdlk

https://github.com/bkeepers/dotenv

D
Dmitri Sinitsa, 2017-05-26
@unabl4

It is more correct to declare a constant (GH_SAVON) rather than a global variable in the so-called initializer. The configuration data itself can be stored in files (the config folder), in yaml or json format, or in any other convenient format.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question