activeadmin 覆盖索引操作

发布于 2024-12-19 21:41:26 字数 793 浏览 1 评论 0原文

我的问题与 ActiveAdmin 中的自定义有关。 首先,我不知道如何覆盖索引操作。根据文档,一切看起来都很简单,但很少有事情能按预期工作。最终我想出了这两种选择。第一个是 博客文章,它提供了以下解决方案(似乎有效) )。

  scope_to do
    Class.new do
      def self.projects
        Project.where(:id => 1)
      end
    end
  end

虽然这个是问题#511 的解决方案,但不起作用。谁能告诉为什么?

  scope_to :current_project

  controller do
    private
    def current_project
      Project.where(:id => 1)
    end
  end

你的经验是什么?如何实现索引动作定制?

我是一位经验丰富的 Web 开发人员,但总体来说我对 Ruby 世界还是个新手。 您认为在生产项目中使用 ActiveAdmin 是个好主意吗?当谈到管理界面时,您会选择什么? 我读过有关 Rails Admin 的内容,但看起来定制起来并不容易。

我目前最担心的是,主动管理不容易自定义以实现与默认提供的 UI 或行为非常不同的 UI 或行为。

你怎么认为?

my problem is related to customization in ActiveAdmin.
First of all I can't get how to override index action. Everything looks simple according to the documentation but very few things work as expected. Eventually I came up with these two alternatives. First one is a blogpost which presents the following solution (which appear to work).

  scope_to do
    Class.new do
      def self.projects
        Project.where(:id => 1)
      end
    end
  end

While this one, which is the solution for issue#511 does not work. Can anyone tell why??

  scope_to :current_project

  controller do
    private
    def current_project
      Project.where(:id => 1)
    end
  end

What's your experience? How do you achieve index action customization?

I'm an experienced web developer but I'm new to Ruby world in general.
Do you think it's a good idea to use ActiveAdmin for a production project? What's you pick when it comes to Admin interface?
I've read about Rails Admin but looks like it's not easy to customize.

My biggest concern at the moment is about active admin not easy to customize to achieve UI or behavior which are very different from the ones that it offers by default.

What do you think?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

聽兲甴掵 2024-12-26 21:41:26

如果您想自定义控制器,请参阅 https://github.com/josevalim/inherited_resources。例如:

controller do
  def index
    # something
    index! do |format|
      format.html { redirect_to some_url }
    end
  end

  protected
  def collection
    @projects ||= end_of_association_chain.paginate(:page => params[:page])
  end
end

If you want to customize controller see https://github.com/josevalim/inherited_resources. For example:

controller do
  def index
    # something
    index! do |format|
      format.html { redirect_to some_url }
    end
  end

  protected
  def collection
    @projects ||= end_of_association_chain.paginate(:page => params[:page])
  end
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文