Ripple with Devise

假如想象 提交于 2019-12-12 13:31:28

问题


Iam Trying to create authentications using devise with riak as the database. I found a ORM strategy for the same https://github.com/frank06/devise-ripple, it does work all fine except for the part that when i try to register with a email which is already present in the db it does not provide a error message instead it overwrites the present data and updates it. The problem I figured is that ripple deals with .save() differently than active record, ie when active record would throw and error Ripple just overwrites it.


回答1:


Since Riak doesn't have a concept of unique fields, you're going to have to check the uniqueness on the app level of your stack.

The way I'd do it is a quick m/r function or even a search/2i check for the count of documents that have the e-mail value you're validating. Everything above 0 is obviously a failed validation.




回答2:


Depending on how you use your keys, you could have the key set to a hash of the email address.

Checking the existence for that specific entry will be as easy as requesting that specific document, should be a lot faster than a map/reduce or search.



来源:https://stackoverflow.com/questions/7888009/ripple-with-devise

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!