Activeadmin:允许访客查看/admin/model.xml

时间:2012-07-10 14:09:25

标签: ruby-on-rails activeadmin

如何允许匿名用户使用Activeadmin查看生成的XML页面?

../管理员/ categories.xml

我尝试添加跳过身份验证过滤器但没有成功。

ActiveAdmin.register Category do
  before_filter :authenticate_user!, :except => [:index]
end

1 个答案:

答案 0 :(得分:1)

如果有人发现此帖子,只需更新。您必须使用cancan设置Activeadmin。

https://groups.google.com/forum/?fromgroups#!topic/activeadmin/uJCkRkrrfHY

请记住使用github的Activeadmin版本。配置此项后,您必须启动虚拟来宾用户 - 将其添加到application_controller.rb

  def authenticate_admin_user!
    current_user ||= AdminUser.new # guest user
  end

现在您必须配置您的cacan权限

class Ability
  include CanCan::Ability

  def initialize(user)
    if user
      can :manage, :all
    else
      can :read, Category
    end
  end
end

cancan截屏视频: http://railscasts.com/episodes/192-authorization-with-cancan