是否可以在activeadmin初始化程序中使用cancan方法,尤其是渲染菜单?

时间:2013-06-19 15:22:38

标签: ruby-on-rails activerecord activeadmin cancan

在activeadmin初始化程序中,我在utility_navigation(right_part)中添加了aditional项。这是代码:

config.namespace :admin do |admin|
  admin.build_menu :utility_navigation do |menu|
    menu.add label: I18n.t('active_admin.menu.import'), url: '/admin/import'
    admin.add_logout_button_to_menu menu
  end
end

我怎么能用?建立菜单时检查访问的方法?我认为,在config cancan中还没有初始化。

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

可以使用:if选项在运行时显示或隐藏菜单项。

Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile(your_file,1)

' dictionary object for collecting and counting the words
dim dictionary: set dictionary = CreateObject("Scripting.Dictionary")
dictionary.CompareMode = 1 'TextCompare

do while not objFileToRead.AtEndOfStream
     strLine = objFileToRead.ReadLine()

     a=Split(strLine," ")
     for each x in a
        ' add new word or increment existing word
        ' you might want to do some sanity checks here
        if not dictionary.exists(x) then
             dictionary.add x, 1
        else
             dictionary(x) = dictionary(x) + 1
        end if
     next
loop

' output the result
dim k
for each k in dictionary.Keys()
    WScript.Echo(k & ":" & dictionary(k) & vbNewLine)
next 'k

将在视图的上下文中调用proc,因此您可以访问所有帮助程序和当前用户会话信息。

Activeadmin Doc