我有这个代码在activeadmin仪表板上创建一个表:
columns do
column do
panel "New Mentor's requests" do
table_for User.where(mentor_request: true) do |t|
t.column("Id") { |user| user.id }
t.column("Name") { |user| user.account.full_name }
t.column("Email") { |user| user.account.email }
t.column("Organization") { |user| user.organization.name }
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
有没有办法像其他资源一样添加"动作"?我的意思是"新的,编辑,删除",但一个自定义的.
我尝试了"actions"标签,但是我得到了一个未定义的方法.
table_for用于呈现可能不一定是 ActiveRecord 对象的对象集合,因此操作方法不像在操作中那样可用index。但是,您应该能够使用以下内容呈现您自己的操作:
column("View User") { |user| link_to "View", user_path(user) }
Run Code Online (Sandbox Code Playgroud)
编辑对于多个链接,您可以link_to使用 Arbre 的 span 标签包装s:
column("View User") do |user|
span link_to "View", "/mypath"
span link_to "Edit", "/mypath"
span link_to "Delete", "/mypath"
end
Run Code Online (Sandbox Code Playgroud)
我正在使用 ActiveAdmin 1.0.0.pre2 和 arbre 1.0.2,我还没有在早期版本上尝试过。
| 归档时间: |
|
| 查看次数: |
2484 次 |
| 最近记录: |