2016-10-25 1 views
0

Hallo Ich habe app_config.yml in meinem Config enthalten bestimmten Code/Ausgabe Mit Blick auf `lesen ': Keine solche Datei oder das Verzeichnis @> in Schienen rb_sysopen

development: 
    name: mytest 
    password: secret 
production: 
    name: test 
    password: Patest 

config/application.rb

require File.expand_path('../boot', __FILE__) 

require 'rails/all' 

# Require the gems listed in Gemfile, including any gems 
# you've limited to :test, :development, or :production. 
Bundler.require(*Rails.groups) 
APP_CONFIG = YAML.load_file("#{::Rails.root}/config/app_config.yml")[::Rails.env] 
Jetzt

app/controllers/application_controller.rb

http_basic_authenticate_with :name => APP_CONFIG[:name], :password => APP_CONFIG[:password] 

wenn ich Schienen-Server ausführen es gibt mir Folgende Fehler ::

config/application.rb: 8: in read': No such file or directory @ rb_sysopen - /config/app_config.yml (Errno::ENOENT) from /Users/rails_app/config/application.rb:8:in '

Bitte leite mich, was ich in meinem Code bin fehlt, wie dieses Problem zu lösen.

+0

hinzugefügt 'to_s' zu Rails.root und überprüft? – Sravan

+0

nein, es funktioniert nicht @Sravan – railslearner

+0

versuchen Sie 'Rails.root.join ('config', 'app_config.yml')' – Sravan

Antwort

0

sollten Sie

APP_CONFIG = YAML.load_file("#{::Rails.root}/config/app_config.yml")[::Rails.env] 

in Ihrem Application Klasse hinzuzufügen.

module Something 
    class Application < Rails::Application 
    # something 

    APP_CONFIG = YAML.load_file("#{::Rails.root}/config/app_config.yml")[::Rails.env] 
    end 
end 
Verwandte Themen