ActiveAdmin——如何引用当前对象?
如何引用当前正在查看的对象的实例?
以下有效
ActiveAdmin.register Example do
sidebar "test" do
@name = example.name
end
end
以下无效
ActiveAdmin.register Example do
member_action :some_stuff, :method => :put do
@name = example.name
end
end
我如何在member_action 中引用该对象?
或者我必须创建另一个实例吗?
How can you reference the instance of the object you are currently viewing?
The following WORKS
ActiveAdmin.register Example do
sidebar "test" do
@name = example.name
end
end
The following DOESN'T Work
ActiveAdmin.register Example do
member_action :some_stuff, :method => :put do
@name = example.name
end
end
How can I reference the object in the member_action?
Or will I have to create another instance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用“资源”对象。
You can use 'resource' object.
大多数有效的管理文档已经过时或完全不存在。如果您想了解如何使用它的详细信息,您可能必须阅读源代码并希望有人对函数进行评论。
member_action
函数文档如下所示:这使得他们看起来希望您在自定义操作中执行自己的对象查找 -
Post.find(params[:id])
。Most of the active admin documentation is out of date or completely nonexistent. You will likely have to read the source and hope somebody commented functions if you want the nitty-gritty on how to use it.
The
member_action
function documentation is as follows:This makes it look like they expect you to perform your own object lookup in custom actions -
Post.find(params[:id])
.