这是来自Rails 教程书:
http://ruby.railstutorial.org/
before_filter :signed_in_user, only: [:create, :destroy]
def signed_in_user
unless signed_in?
store_location
redirect_to signin_url, notice: "Please sign in."
end
end
def signed_in?
!current_user.nil?
end
因此,代码只允许用户在登录后创建和销毁帖子。
我想知道是否使用Devise before_filter :authenticate_user!, only: [:create, :destroy]
这样做。结果是一样的吗?