将页面添加到活动管理员 [英] Add page to active admin

查看:53
本文介绍了将页面添加到活动管理员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想向我们的管理员添加帮助页面,并且正在使用活动的admin gem。该页面未与任何模型关联,因此我努力尝试弄清楚如何使链接显示在每个页面的菜单栏中。

We are wanting to add a help page to our admin and we are using the active admin gem. This page is not associated to any model so I am struggling trying to figure out how to get the link to show up in the menu bar on every page.

推荐答案

警告:这绝望地过时了,并且在2020年不再适用。这是针对activeadmin< 0.7版本的。

使用此内容制作文件/app/models/help.rb,对于更高级的无表模型,您可以想要查看 http://keithmcdonnell.net/activerecord_tableless_model_gem.html 或一起搜索您自己的见解。

Make a file /app/models/help.rb with this contents, for more advanced tableless models you might want to check out http://keithmcdonnell.net/activerecord_tableless_model_gem.html or google your own insight together.

class Help < ActiveRecord::Base

  def self.columns 
    @columns ||= []
  end

  # ...  

end

将条目添加到/config/initializers/inflections.rb

add an entry to /config/initializers/inflections.rb

ActiveSupport::Inflector.inflections do |inflect|
  inflect.uncountable %w( help )
end

设置路线对于您的Viewlogger,在config / routes.rb中:

set up a route for your viewlogger, in config/routes.rb:

match '/admin/help' => 'admin/help#index', :as => :admin_help

现在您可以按如下方式制定activeadmin注册块(确保您创建了部分视图

now you can formulate the activeadmin register block as follows (make you sure you create a view partial in the right place)

ActiveAdmin.register Help do      
  config.comments = false
  before_filter do @skip_sidebar = true end
  # menu false
  config.clear_action_items!   # this will prevent the 'new button' showing up    
  controller do
    def index
      # some hopefully useful code
      render 'admin/help/index', :layout => 'active_admin'
    end
  end   

end

这篇关于将页面添加到活动管理员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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