Reputation: 774
I just configured Mongoid for a Rails project, ran rails g mongoid:config
edited my mongoid.yml
to be like below.
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
Then went on thinking everything to be running fine, to scaffold a controller and model called Activity
. With that I ran rails s
. The app runs fine at localhost:3000
, but the moment I get to localhost:3000/activites
it spits out this.
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'
Any ideas?
Upvotes: 0
Views: 7183
Reputation: 1
Mongo runs on port 27017 by default, try to change your hosts configuration to localhost:27017 in your mongoid.yml.
Upvotes: 0
Reputation: 26
You are running mongo right? Probably with 'mongod' if you're on a mac or 'sudo service mongod start'. Might be a stupid answer but you never know
Upvotes: 1