Ruby on rails 从使用Heroku的github克隆的rails应用程序存在访问问题

Ruby on rails 从使用Heroku的github克隆的rails应用程序存在访问问题,ruby-on-rails,heroku,github,Ruby On Rails,Heroku,Github,我已经从GitHub克隆了一个项目,现在我无法在本地运行它 我在浏览器中遇到此错误: Moped::Errors::ConnectionFailure at / Could not connect to any secondary or primary nodes for replica set <Moped::Cluster nodes=[<Moped::Node resolved_address="127.0.0.1:27017">]> 我是Rails新手,所以简单

我已经从GitHub克隆了一个项目,现在我无法在本地运行它

我在浏览器中遇到此错误:

Moped::Errors::ConnectionFailure at /
Could not connect to any secondary or primary nodes for replica set <Moped::Cluster nodes=[<Moped::Node resolved_address="127.0.0.1:27017">]>
我是Rails新手,所以简单的说明/建议会很好

这是我的mongoid.yml文件中的内容

development:
  # Configure available database sessions. (required)
  sessions:
# Defines the default session. (required)
default:
  # Defines the name of the default database that Mongoid can connect to.
  # (required).
  database: disrupt_development
  # Provides the hosts the default session can connect to. Must be an array
  # of host:port pairs. (required)
  hosts:
    - localhost:27017
  options:
    # Change whether the session persists in safe mode by default.
    # (default: false)
    # safe: false

    # Change the default consistency model to :eventual or :strong.
    # :eventual will send reads to secondaries, :strong sends everything
    # to master. (default: :eventual)
    # consistency: :eventual

    # How many times Moped should attempt to retry an operation after
    # failure. (default: 30)
    # max_retries: 30

    # The time in seconds that Moped should wait before retrying an
    # operation on failure. (default: 1)
    # retry_interval: 1
  # Configure Mongoid specific options. (optional)
  options:
# Configuration for whether or not to allow access to fields that do
# not have a field definition on the model. (default: true)
# allow_dynamic_fields: true

# Enable the identity map, needed for eager loading. (default: false)
# identity_map_enabled: false

# Includes the root model name in json serialization. (default: false)
# include_root_in_json: false

# Include the _type field in serializaion. (default: false)
# include_type_for_serialization: false

# Preload all models in development, needed when models use
# inheritance. (default: false)
# preload_models: false

# Protect id and type from mass assignment. (default: true)
# protect_sensitive_fields: true

# Raise an error when performing a #find and the document is not found.
# (default: true)
# raise_not_found_error: true

# Raise an error when defining a scope with the same name as an
# existing method. (default: false)
# scope_overwrite_exception: false

# Skip the database version check, used when connecting to a db without
# admin access. (default: false)
# skip_version_check: false

# User Active Support's time zone in conversions. (default: true)
# use_activesupport_time_zone: true

# Ensure all times are UTC in the app side. (default: false)
# use_utc: false
test:
  sessions:
default:
  database: disrupt_test
  hosts:
    - localhost:27017
  options:
    consistency: :strong
    # In the test environment we lower the retries and retry interval to
    # low amounts for fast failures.
    max_retries: 1
    retry_interval: 0


production:
  sessions:
default:
  uri: <%= ENV['MONGOHQ_URL'] %>
开发:
#配置可用的数据库会话。(必选)
会议:
#定义默认会话。(必选)
违约:
#定义Mongoid可以连接到的默认数据库的名称。
#(必需)。
数据库:中断开发
#提供默认会话可以连接到的主机。必须是数组
#主机类型:端口对。(必选)
主持人:
-本地主机:27017
选项:
#更改会话是否默认保持在安全模式。
#(默认值:false)
#安全:错误
#将默认一致性模型更改为:final或:strong。
#:final将向二级数据库发送读取,:strong将发送所有内容
#掌握。(默认:最终)
#一致性:最终的
#之后,Moped应尝试重试操作多少次
#失败。(默认值:30)
#最多重试次数:30次
#轻便摩托车在重试前应等待的时间(以秒为单位)
#故障时的操作。(默认值:1)
#重试间隔:1
#配置特定于Mongoid的选项。(可选)
选项:
#是否允许访问不允许访问的字段的配置
#模型上没有字段定义。(默认值:true)
#允许\u动态\u字段:true
#启用即时加载所需的标识映射。(默认值:false)
#已启用标识映射:false
#在json序列化中包含根模型名称。(默认值:false)
#将_root_包含在_json中:false
#在序列化中包含_type字段。(默认值:false)
#包含\u序列化的\u类型\u:false
#预加载开发中的所有模型(模型使用时需要)
#继承权。(默认值:false)
#预加载\u模型:错误
#保护id和类型不受质量分配的影响。(默认值:true)
#保护敏感字段:true
#执行#查找但未找到文档时引发错误。
#(默认值:true)
#raise\u not\u found\u错误:true
#定义与对象同名的作用域时引发错误
#现有方法。(默认值:false)
#范围覆盖异常:false
#跳过数据库版本检查,该检查在连接到数据库时使用
#管理员权限。(默认值:false)
#跳过版本检查:false
#用户活动支持的时区转换。(默认值:true)
#使用\u activesupport\u时区:true
#确保应用程序端的所有时间均为UTC。(默认值:false)
#使用utc:false
测试:
会议:
违约:
数据库:中断测试
主持人:
-本地主机:27017
选项:
一致性:强
#在测试环境中,我们将重试次数和重试间隔降低到
#快速故障的低金额。
最大重试次数:1次
重试间隔:0
制作:
会议:
违约:
uri:

您没有正确设置
生产环境(或其他环境)的
uri

yml
文件格式不知道顶级键之间的区别(默认:和生产:将视为独立键,因为它们没有嵌套)

假设您在Heroku上使用Mongohq3.x,请尝试更改

production:
  sessions:
default:
  uri: <%= ENV['MONGOHQ_URL'] %>
生产:
会议:
违约:
uri:
…到

production:
  sessions:
    default:
      uri: <%= ENV['MONGOHQ_URL'] %>
生产:
会议:
违约:
uri:

应该有更多关于mongoid.yml中的内容的信息?我已经在上面添加了文件内容对不起,这是我的一个错误,文件格式正确,但在复制和粘贴时,我没有正确缩进文本。还有其他建议吗?
production:
  sessions:
    default:
      uri: <%= ENV['MONGOHQ_URL'] %>