Kir*_*kin 5 ruby ruby-on-rails inherited-resources activeadmin
我想通过activeadmin创建设置页面(编辑/更新). https://github.com/huacnlee/rails-settings-cached.
但我面临着没有办法在特定页面的路由中注册资源(而不是资源),例如有/ admin/settings之类的路由,但不是admin/settings /:id
inherit_resource有
defaults singleton: true
Run Code Online (Sandbox Code Playgroud)
对于这种情况,但这对activeadmin不起作用.
请帮忙.
否则,我可以使用register_pagse方式自己创建表单并更新操作,但是出现了另一个问题:如何从该更新操作在表单上呈现错误消息.
单身方式是首选方式.
小智 3
您始终可以强制index操作重定向到您想要的单例资源。虽然这不是一个完美的解决方案,但我过去曾使用过它。像这样的东西:
ActiveAdmin.register Setting, as: 'Setting' do
actions :all, only: [:show, :edit, :update, :index]
controller do
def index
redirect_to resource_path(Setting.first)
end
end
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
596 次 |
| 最近记录: |