title: how to access the yml file from application.js in rails?
body: <p>I have a yml file and i need the keys to be used in the application.js file in the scripts. I cannot able to access it from the script. Please help me. I have the following lines in the initializer</p>
  
  <pre><code>APP_CONFIG = YAML.load_file("#{Rails.root}/config/filename.yml")[Rails.env]
  </code></pre>
  
  <p>and i have the following keys in my yml file</p>
  
  <pre><code>development:
    key1: 782364764527225794828437
    key2: sdjfbjs7e834284383984729
    key3: 73465365egfrf36462874727
  </code></pre>
  
  <p>and i access the keys in application.js file as </p>
  
  <pre><code>APP_CONFIG['key1']
  </code></pre>
  
  <p>but it seems to take nothing. But when i print the same thing in the view body as</p>
  
  <pre><code>&lt;%= APP_CONFIG['key1'] %&gt;
  </code></pre>
  
  <p>then it returns the value of the key1.</p>
  
  <p>What should i do to access the value in application.js file. It also not works in the script body in the view itself.</p>