【发布时间】:2018-07-24 20:07:16
【问题描述】:
我刚刚为 Rails 项目配置了 Mongoid,运行 rails g mongoid:config 将我的 mongoid.yml 编辑为如下所示。
development:
clients:
default:
database: abacus_development
# Provides the hosts the default client can connect to. Must be an array
# of host:port pairs. (required)
hosts:
- localhost
options:
test:
clients:
default:
database: abacus_test
hosts:
- localhost
options:
read:
mode: primary
max_pool_size: 1
然后继续认为一切都运行良好,搭建一个名为 Activity 的控制器和模型。于是我跑了rails s。该应用程序在localhost:3000 运行良好,但当我到达localhost:3000/activites 时,它会吐出这个。
ActionView::Template::Error (No server is available matching preference: #<Mongo::ServerSelector::Primary:0x007fbda47c4110 @tag_sets=[], @options={:database=>:abacus_development}, @server_selection_timeout=30>):
15: </thead>
16:
17: <tbody>
18: <% @activities.each do |activity| %>
19: <tr>
20: <td><%= activity.amount %></td>
21: <td><%= activity.indicator %></td> app/views/activities/index.html.erb:18:in `_app_views_activities_index_html_erb___73038992978597028_70226242222820'
有什么想法吗?
【问题讨论】:
标签: ruby-on-rails mongodb