活动管理员用户管理列表
我希望生成所有注册用户的列表以及创建日期和 IP 地址。 最重要的功能是能够从此列表中删除用户。
Active_admin 似乎是此任务的最佳选择,但我发现此场景的结果很少。我觉得很难相信,因为我认为这是一个常见的特征。
有任何建议或教程链接吗?
提前致谢!
编辑:
好的,所以我通过主动管理创建了用户资源。即 /app/admin/user.rb
然后我拿了一些 active_admins 演示代码并将其修剪以进行测试。
ActiveAdmin.register User, :as => "User" do
filter :username
filter :email
filter :created_at
index do
id_column
column :username
column :email
column :created_at
default_actions
end
end
但我收到错误:
Admin::UsersController#index 中出现 NoMethodError
[]:ActiveRecord::Relation 的未定义方法“per”
有什么想法吗?
编辑2:我刚刚尝试过:
ActiveAdmin.register User do
def index
@users = User.find(:all)
end
end
并且我得到了同样的错误。
EDIT3:
发现问题。经过一番挖掘, will_paginate gem 导致了冲突!
现在一切正常了!
I'm looking to generate a list of all users signed up as well as a created date and an IP address.
The most important feature is the ability to delete users from this list.
Active_admin seems to be the best choice for this task, but I have found very few results for this scenario. I find it hard to believe because I would assume that this is a common feature.
Any suggestions or links to tutorials?
Thanks in advance!
EDIT:
Ok, so I went and created a user resource through active admin. I.e /app/admin/user.rb
I then went and took some of active_admins demo code and trimmed it down for testing.
ActiveAdmin.register User, :as => "User" do
filter :username
filter :email
filter :created_at
index do
id_column
column :username
column :email
column :created_at
default_actions
end
end
But I get the error:
NoMethodError in Admin::UsersController#index
undefined method `per' for []:ActiveRecord::Relation
Any ideas?
EDIT 2: I just tried:
ActiveAdmin.register User do
def index
@users = User.find(:all)
end
end
and I get the same exact error.
EDIT3:
Found the issue. After some digging, will_paginate gem was causing the conflict!
Everything works now!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Active Admin,您可以显示您拥有的每个模型的数据。例如,当您有一个模型
user
(您的前端用户)时,您只需创建/app/admin/users.rb
并将您的内容放入其中。完成的。你可以看一下 github 上 activeadmin.info 的代码
With Active Admin, you can display data from every model you have. When for example you have a model
user
(your front-end users), you just create/app/admin/users.rb
and put your stuff in there. Finished.You can have a look at the code of activeadmin.info on github.