ActiveAdmin-如何在自定义操作中呈现默认模板 [英] ActiveAdmin - how to render default template in customized action

查看:78
本文介绍了ActiveAdmin-如何在自定义操作中呈现默认模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Rails3应用程序中使用ActiveAdmin作为默认模型。现在我们需要覆盖show操作。 OrderProcess模型是一个瞬态(无表)模型,这意味着所有字段都是从其他数据中聚合的。我们使用一个内部模块,该模块提供必要的方法来模拟ActiveAdmin所依赖的MetaSearch方法。以下是我们如何覆盖show操作的方法:

We are using ActiveAdmin in our Rails3 application for the default models. Now we needed to overwrite the show action. The OrderProcess model is a transient (tableless) model, which means that all fields are aggregated from other data. We use an internal module that provides the necessary methods to mock the MetaSearch methods ActiveAdmin is depending on. The following is how we overwrite the show action:

ActiveAdmin.register OrderProcess do  
  member_action :show, :method => :get do
    @order_process = OrderProcess.all_orders_for_deal(params['id'])
  end
end

这使我们抱怨缺少模板缺少模板admin / order_processes / show with ...

That gives us an error complaining about a missing template "Missing template admin/order_processes/show with ..."

尝试调用

  render renderer_for(:show)

,但是这会导致关于缺少方法model_name的错误,这可能是由于我们的模型是无表的和有关模块。

but that produced an error about a missing method model_name which may be due to our model being tableless and the regarding module.

我们如何使用内置的渲染方法ActiveAdmins显示我们的模型?

How can we use ActiveAdmins built in rendering methods to display our model? Any help is appreciated.

推荐答案

刚遇到这个问题... Grant的评论正确, active_admin_template 不再存在(我在1.0.0-pre2上)。

Just ran into this... Grant's comment is correct, active_admin_template doesn't exist any more (I'm on 1.0.0-pre2).

我最终选择了:

render:action => :edit,:layout => false

这似乎可行,尽管您必须为标头提供标签,标签显示为缺少翻译:en.active_admin 。[您的操作] _模型

which seems to work, although you will have to supply a label for the header, which displays as "translation missing: en.active_admin.[your_action]_model"

这篇关于ActiveAdmin-如何在自定义操作中呈现默认模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆