ActiveAdmin 如何与现有控制器配合使用
我发现很难理解 ActiveAdmin(http://activeadmin.info/) 如何与现有控制器一起工作
我有以下控制器
app/controllers/projects_controller.rb
,并且我成功地能够在上述控制器中的视图上实现 ActiveAdmin UI。但我的问题是我在控制器中添加了以下 before_filter
class StaticContentsController < ApplicationController
before_filter :list_content_types
def index
@static_contents = StaticContent.all
end
end
但是这个过滤器似乎没有执行,事实上我将索引方法内的代码更改为
@static_contents = abc StaticContent.all
因为“abc”部分而应该给出错误,但令人惊讶的是我的应用程序工作没有错误。我的猜测是“ActiveAdmin”读取我自己的控制器,而不是现有的控制器
这是我的索引操作路径
http://localhost:3000/admin/static_contents
,并且处于开发模式
有人可以帮助我了解控制器如何与 ActiveAdmin 一起使用还是我在这里遗漏了一些内容
以下是我的配置
轨道(3.0.0) 红宝石 1.8.7 activeadmin (0.3.2)
提前感谢
Sameera
I'm finding it difficult to understand how ActiveAdmin(http://activeadmin.info/) works with existing controllers
I have the following controllers
app/controllers/projects_controller.rb
and I was successfully able to implement ActiveAdmin UI over my views in the above controller. But my question is I have added the following before_filter in my controller
class StaticContentsController < ApplicationController
before_filter :list_content_types
def index
@static_contents = StaticContent.all
end
end
But this filter seems to be not executing, in fact I changed the code inside the index method to
@static_contents = abc StaticContent.all
As it should give and error because of 'abc' section, but surprisingly my app works with out an error. My guess is 'ActiveAdmin' reads controllers my its own, not the existing ones
this is my index action path
http://localhost:3000/admin/static_contents
and this is in development mode
Can someone help me on understanding how controllers works with ActiveAdmin or am I missing something here
Following are my configs
rails (3.0.0)
ruby 1.8.7
activeadmin (0.3.2)
thanks in advance
sameera
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Activeadmin 控制器与应用程序的控制器不同,它们是独立的。您的代码没有导致 activeadmin 界面出现异常的原因是因为该代码永远不会被命中。 activeadmin 控制器文档指定如何修改默认的 activeadmin 操作。
Activeadmin controllers are not the same as your app's controllers, they are separate. The reason your code is not causing an exception from the activeadmin interface is because that code is never hit. The activeadmin controller documentation specifies how to modify the default activeadmin actions.