【发布时间】:2017-11-10 12:39:57
【问题描述】:
在我的 Rails 应用程序中,我安装了 active admin。在users index 页面中,默认情况下会显示all columns(用户表列)。我想添加一个custom column called "become user" in this users index view(它不是用户表中的一列)。在此column 下,我想将user name 显示为hyperlink。单击该链接后,admin 将登录到该特定用户帐户。为了实现这个切换功能,我使用switch user gem。如何在Active Admin 中自定义这个视图?以及如何为活动管理员中的所有用户生成链接
ActiveAdmin.register User do
permit_params do
permitted = [:email, :fname, :lname, :phone]
# permitted << :other if resource.something?
# permitted
end
# Filterable attributes on the index screen
filter :email
filter :fname
filter :lname
filter :phone
filter :current_sign_in_at
filter :created_at
# Customize columns displayed on the index screen in the table
index do
selectable_column
id_column
column :email
column :fname
column :lname
column :phone
column :current_sign_in_at
# column :sign_in_count
column :created_at
# actions
end
form do |f|
inputs 'Details' do
input :email
input :password
input :fname
input :lname
input :phone
end
actions
end
controller do
end
end
【问题讨论】:
-
你能粘贴你的
ActiveAdmin为User模型设置吗? -
你好约翰,你总是在没有代码的情况下粘贴这样的问题。请阅读该社区stackoverflow.com/help/how-to-ask 的规则,您过去粘贴了一个类似的问题,广泛且不包括代码示例stackoverflow.com/questions/46033523/… 以及另一个stackoverflow.com/questions/44971139/…
-
嗨,@AntonTkachov。我用代码更新了问题
标签: ruby-on-rails views customization activeadmin