简体   繁体   English

无法启动Rails服务器

[英]Can't get rails server to start

When I try to start my rails server in the environment "mainstreet" this function in my config/site_config.rb file 当我尝试在“ mainstreet”环境中启动我的Rails服务器时,此功能在我的config / site_config.rb文件中

def self.settings(env)
    answer = YAML::load_file('config/siteconfig.yml')[env]
    raise "No settings for environment #{env}" if answer.nil?
    answer
end

returns "No settings for the environment mainstreet" In siteconfig.yml I have: 返回“在环境mainstreet上没有设置”在siteconfig.yml中,我有:

mainstreet:
environment: mainstreet
S3_DOC_BUCKET: 
PPTX_GEN_SERVICE:
PDF_GEN_SERVICE: 
OBJ_THUMB_SERVICE: 
WINDOWS_CLIENT_URL: 
KM_KEY:
HOST_NAME: http://localhost:3000

and I have a mainstreet.rb file in /config with settings defined. 而且我在/ config中有一个mainstreet.rb文件,其中定义了设置。 I'm new to ruby, so I'm not sure whats going on here, I've never had an issue like this. 我是红宝石的新手,所以我不确定这里发生了什么,我从未遇到过这样的问题。 Also, I'm using windows. 另外,我正在使用Windows。

Here's the full trace: 这是完整的痕迹:

Sounds like the current directory isn't what you think it is...You need to specify the full path to your config file: 听起来好像当前目录不是您想的那样...您需要指定配置文件的完整路径:

def self.settings(env)
    path = File.join(Rails.root, "config", "siteconfig.yml")
    answer = YAML::load_file(path)[env]
    raise "No settings for environment #{env}" if answer.nil?
    answer
end

EDIT: Your config file is badly formatted, if what you have here is correct. 编辑:如果您的配置正确,则您的配置文件格式错误。 It should be indented: 应该缩进:

mainstreet:
    environment: mainstreet
    S3_DOC_BUCKET: 
    PPTX_GEN_SERVICE:
    PDF_GEN_SERVICE: 
    OBJ_THUMB_SERVICE: 
    WINDOWS_CLIENT_URL: 
    KM_KEY:
    HOST_NAME: http://localhost:3000

In a rails3 console, the file parses correctly: 在rails3控制台中,文件正确解析:

irb(main):039:0> y = YAML.load_file("c.yml")["mainstreet"]
=> {"environment"=>"mainstreet", "S3_DOC_BUCKET"=>nil, "PPTX_GEN_SERVICE"=>nil, "PDF_GEN_SERVICE"=>nil, "OBJ_THUMB_SERVICE"=>nil, "WINDOWS_CLIENT_URL"=>nil, "KM_KEY"=>nil, "HOST_NAME"=>"http://localhost:3000"}

This assumes you're passing "mainstreet" as the value of env in your function 假设您要在函数中传递“ mainstreet”作为env的值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM