* Railsのmongoidでユーザ認証 [#od9e45ba]
#setlinebreak(on);
#contents
-- 関連
--- [[MongoDB]]
--- [[Ruby on Rails]]
--- [[Railsメモ]]
** MongoDBでユーザ作成 [#e7fc4b93]
#myterm2(){{
use admin;
db.createUser(
{
user:"作成したいユーザー名",
pwd:"パスワード",
roles:[
{
"role" : "dbOwner",
"db" : "DB名"
}
]
}
);
}}
** /etc/mongod.conf を作成 [#d742b1cd]
#mycode2(){{
auth = true
}}
** MongoDB起動 [#e6140c47]
#myterm2(){{
mongod -f /etc/mongod.conf
}}
** mongoid.yml に追記 [#iff61920]
#mycode2(){{
development:
sessions:
default:
options:
user: "user1"
password: "user1"
roles:
- 'dbOwner'
}}
** Rails起動 [#z42fe72b]
#myterm2(){{
rails s
}}