如何在每个记录的基础上指定可用的 ActiveScaffold 操作?
我的 Rails 2 应用程序中有一个非常简单的管理控制器,它显示模型只读的所有记录:
class Admin::InspectionsController < ApplicationController
active_scaffold :inspections do |config|
[:create, :update, :delete].each {|a| config.actions.exclude a}
config.actions.exclude :nested
end
end
我希望使这些模型对象可编辑,但前提是它们处于某种状态(即,在它们被编辑之前)。得到正式认可的)。我可以通过从排除列表中删除 :update 来对所有检查
执行此操作,但我不想启用批量编辑。
有没有办法为 ActiveScaffold 指定条件操作?
I have a very simple admin controller in my Rails 2 app that displays all the records for a model read-only:
class Admin::InspectionsController < ApplicationController
active_scaffold :inspections do |config|
[:create, :update, :delete].each {|a| config.actions.exclude a}
config.actions.exclude :nested
end
end
I wish to make these model objects editable, but only if they are in a certain state (ie, before they've been approved). I can do this for all Inspections
by removing :update from the exclusions list, but I don't want to enable editing wholesale.
Is there a way to specify conditional actions to ActiveScaffold?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想你正在寻找这个: https://github.com/activescaffold/active_scaffold/wiki/Security 。前往“模型方法:限制其他任何内容”
长话短说,您启用所有操作,然后将方法添加到模型定义中以切换每个记录的所述操作,如链接中所述。
I think you are looking for this: https://github.com/activescaffold/active_scaffold/wiki/Security. Head down to 'Model Methods: Restricting Anything Else'
Long story short, you enable all actions, and then add methods to your model definition to toggle said actions for each record, as described in the link.