Skip to content

Commit 4c637da

Browse files
author
hiroshi
committed
Connect to docker compose mongo service.
1 parent d6c6932 commit 4c637da

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

app/models/topic.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Topic
2+
include Mongoid::Document
3+
4+
field :title, type: String
5+
validates :title, presence: true
6+
end

config/mongoid.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ development:
1313
# Provides the hosts the default client can connect to. Must be an array
1414
# of host:port pairs. (required)
1515
hosts:
16-
- localhost:27017
16+
- mongo:27017
1717
options:
1818
# Note that all options listed below are Ruby driver client options (the mongo gem).
1919
# Please refer to the driver documentation of the version of the mongo gem you are using

docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ services:
1212
command: ['bundle', 'exec', 'rails', 's', '-b', '0.0.0.0']
1313
environment:
1414
RAILS_ENV: development
15+
mongo:
16+
image: mongo
17+
1518

1619
volumes:
1720
bundle:

0 commit comments

Comments
 (0)