新版本 devise 1.5 和omniauth 1.0.0 facebook 与 Mongoid 的手册
中的新版本设计安装新版本omniauth 1.0.0 的新手册
我正在按照https ://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
但我认为本手册适用于 Mysql。我正在使用Mongoid。
我尝试更新mongoid语法的查询:
在omniauth_callbacks_controller.rb中,
如果@user.persisted?我已经更改通过 if @user.create
在模型 user.rb 中,
我更改了 if user = User.find_by_email(data.email) 通过if user = User.where(email: (data.email))
问题是,当用户从 facebook 返回时,在回调中我收到下一个错误:
Could not find a valid mapping for #<Mongoid::Criteria
selector: {:email=>"emailusercomebackfacebook"},
options: {},
class: User,
embedded: false>
知道吗?我在哪里可以获得 Mongoid 的新设备和omniauth 的指南或手册?
谢谢你!
I am following the new manual for install new version omniauth 1.0.0 with new version devise in
https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
But this manual its for Mysql I think. Im working with Mongoid.
I have try update the query for the mongoid syntax:
In omniauth_callbacks_controller.rb
if @user.persisted? I have changed by if @user.create
In the model user.rb
I have change if user = User.find_by_email(data.email) by if user = User.where(email: (data.email))
The problem is that in callback when the user come back from facebook I get the next error:
Could not find a valid mapping for #<Mongoid::Criteria
selector: {:email=>"emailusercomebackfacebook"},
options: {},
class: User,
embedded: false>
Any idea? Where can I get a guide or manual for new devise and omniauth for Mongoid?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,您需要做两处更改:
1)
User.find_by_email(data.email)
需要是User.where(:email => data.email).first
2)
User.create!(:email => data.email, :encrypted_password => Devise.Friendly_token[0,20])
需要User.create!(:email => data.email, :password => Devise.friend_token[0,20], :name => "Dummy Name")
注意我正在使用 "上面的虚拟名称,您应该从 Facebook 数据中获取名称。
Yes, you need to do two changes:
1)
User.find_by_email(data.email)
needs to beUser.where(:email => data.email).first
2)
User.create!(:email => data.email, :encrypted_password => Devise.friendly_token[0,20])
needs to beUser.create!(:email => data.email, :password => Devise.friendly_token[0,20], :name => "Dummy Name")
Notice I am using "Dummy Name" above, you should get the name from facebook data instead.
尝试获取第一个元素,看看它是否是您想要的实例。 Mongoid 似乎正在返回一个带有元素的 Enumerable 。
Try to get the first element and see if it is the instance you want. Mongoid seems to be returning a Enumerable with the elements.
我已将下一个查询添加到模型中:
现在错误出现在模型中:
使用新查询,脚本将转到 if 句子中的 else
产生错误的行其他是:
尝试使用存根密码创建用户
I have add the next query to model:
Now the error is in the model:
With the new query the script go to else in the if sentence
The line that produce the error in the else is:
To try create the user with stub password