Mongoid で Amistad を使い始めたばかりで、 current_user.invite(@user) が Mongo に保存されていないことがわかりました。コンソールと Rails アプリケーションでこれを実行しました。メソッドが true を返すため、メソッドが機能すると判断しましたが、データは保持されません。他の誰かがこの問題を抱えていますか? 私のmongo dbは機能します。私はそれであらゆる種類のデータを保存しましたが、アミスタッドの友達の方法はそうではありません.
コントローラーのアクションは次のとおりです。
def invite_friend
@user = User.find params['id']
res = current_user.invite(@user)
current_user.last_name = 'hamilton123'
current_user.save
respond_to do |format|
format.html
format.js{ render :js => "$('#friend_#{params['id']}').text('Pending')" }
end
end
.invite() 実行後のログ出力の一部を次に示します。また、mongo が保存を出力するのを確認できるように、current_user.save() も実行しました。
MONGODB yansn_development['system.namespaces'].find({})
MONGODB yansn_development['users'].find({:_id=>BSON::ObjectId('4f8b100dbf0d820513000007')}).limit(-1).sort([[:_id, :asc]])
MONGODB yansn_development['users'].find({:_id=>BSON::ObjectId('4f8b0fd2bf0d82055b000001')}).limit(-1).sort([[:_id, :asc]])
MONGODB yansn_development['users'].update({"_id"=>BSON::ObjectId('4f8b100dbf0d820513000007')}, {"$set"=>{"last_name"=>"hamilton123", "updated_at"=>2012-04-15 19:06:21 UTC}})
Invite() メソッドを保存するべきではありませんか?