rails4:康康舞还是康康舞?使用has_secure_password [英] rails4: cancan or cancancan? with has_secure_password

查看:95
本文介绍了rails4:康康舞还是康康舞?使用has_secure_password的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现某种类型的用户,以便那些用户可以编辑数据而其他用户只能读取。

I'm trying to implement some type of users so ones can edit data and other can only read.

user.rb

class User < ActiveRecord::Base
    has_secure_password
    validates_presence_of :email, :password, :on => :create
end

我正在使用 has_secure_password (我遵循 http://railscasts.com/episodes/270-会话的authentication-in-rails-3-1?view = asciicast ),我发现可以,但是我发现了这一点:

I'm using has_secure_password(I followes http://railscasts.com/episodes/270-authentication-in-rails-3-1?view=asciicast) for sessions and I found cancan but I found this:

http://rubygems.org/gems/cancan http://rubygems.org/gems/cancancan

那么,有什么区别?我必须使用哪个?

so, what is the difference? which must I use?

本指南,可以说是一个很好的起点,还是我应该寻找其他方法?

is this guide for rails 3.1 and cancan a good start point or should I look for another approach?

我是有滑轨的新手,谢谢。

I'm newbie with rails, thanks in advance.

推荐答案

CanCan项目已失效,CanCanCan是为Rails 4提供类似授权解决方案的单独项目。简而言之,CanCan适用于Rails 3应用程序,而CanCanCan适用于Rails 4应用程序。这是另一个Stackoverflow答案,其中包含有关CanCan / CanCanCan的更多信息。

The CanCan project is dead and CanCanCan is a separate project to make a similar authorization solution for Rails 4. In short, CanCan is suitable for Rails 3 apps and CanCanCan is suitable for Rails 4 apps. Here is another Stackoverflow answer with some more information about CanCan / CanCanCan.

这篇关于rails4:康康舞还是康康舞?使用has_secure_password的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆