为需要身份validation的操作设计操作筛选器

我正在使用设计进行身份validation,但是我无法看到和操作filter来指定需要用户登录的操作,这是否包含在设计gem中? 如果不是我怎么能创建一个,我有一个想法,但因为我是铁杆新手,我宁愿首先看一个更有经验的程序员的解决方案。

请参阅设计自述文件 。

class PostsController < ApplicationController respond_to :html # Tell Devise that the #destroy action is # special, and that the user must be # authenticated in order to access the # #desroy action. # Note that the name of the method here, # #authenticate_user!, depends on the # particular class/table that you have # set up to be managed with Devise. before_filter :authenticate_user!, :only => [:destroy] before_filter :find_post!, :only => [:destroy] def destroy @post.destroy respond_with @post end private def find_post! @post = Post.find(params[:id]) end end 

另一个解决方案是使用例如:except => login,它在整个应用程序使用身份validation时使用,并且您希望拥有一个具有公共访问权限的页面