ActiveAdmin记录激活页面?

发布于 2024-12-11 07:35:39 字数 680 浏览 0 评论 0原文

我正在开发一个应用程序,管理员必须在显示“主题”之前激活该应用程序。主题表只有一个名为 active 的列。

我将 ActiveAdmin gem 用于管理面板的其余部分,并且我还有一个主题编辑页面,可以在其中更改主题的各个方面。但是,我还希望有一个主题的辅助页面,该页面仅显示该标题,并可以激活该主题(无法更改其他列)。我确信这会更加用户友好,但我不知道如何去做,或者是否可能。

我的印象是每个模型只能创建一个编辑页面。

有什么想法吗?

编辑

topic.erb

class Topic < ActiveRecord::Base

  scope :pending, where(:active => false)

  validates_presence_of :title, :description, :user_id
  belongs_to :user

  has_many :solutions
  accepts_nested_attributes_for :solutions, :allow_destroy => true, :reject_if => Proc.new{|attributes| attributes["title"].blank?}

  acts_as_taggable

end

I'm working on an application for which the admin has to activate 'topics' before they are shown. The topics table simply has a column called active.

I'm using the ActiveAdmin gem for the rest of the admin panel and I also have an edit page for topics where every aspect of the topic can be changed. However, I would also like to have a secondary page for topics which would only display that title, and make it possible to activate the topic (without being able to change the other columns). I'm sure this would be more user-friendly, but I don't know how to go about it, or if it is even possible.

I have the impression that only one edit page can be made for each model.

Any ideas?

EDIT

topic.erb

class Topic < ActiveRecord::Base

  scope :pending, where(:active => false)

  validates_presence_of :title, :description, :user_id
  belongs_to :user

  has_many :solutions
  accepts_nested_attributes_for :solutions, :allow_destroy => true, :reject_if => Proc.new{|attributes| attributes["title"].blank?}

  acts_as_taggable

end

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

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

发布评论

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

评论(1

躲猫猫 2024-12-18 07:35:39

我现在无法自己尝试,但我想说您需要这样的 ActiveAdmin 配置:

ActiveAdmin.register Topic do
  scope :pending

  menu :label => 'Activate Topics'

  # if you want it as submenu of 'Topic':
  # menu :parent => 'Topic'

  index do
    column :active
  end
end

其中 pending 范围将是一个模型范围,用于仅显示待处理(非活动)主题。喜欢:

class Topic < ActiveRecord::Base
  scope :pending, where(:active => false)

  # ...
end

最好的问候

托比亚斯

I can't try it right now myself, but I'd say you want something like this as ActiveAdmin configuration:

ActiveAdmin.register Topic do
  scope :pending

  menu :label => 'Activate Topics'

  # if you want it as submenu of 'Topic':
  # menu :parent => 'Topic'

  index do
    column :active
  end
end

Where the pending scope would be a model scope for just showing the pending (not active) topics. Like:

class Topic < ActiveRecord::Base
  scope :pending, where(:active => false)

  # ...
end

Best Regards

Tobias

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文