Rails 3.如何添加ActiveAdmin将使用的帮助程序? [英] Rails 3. How to add a helper that ActiveAdmin will use?

查看:77
本文介绍了Rails 3.如何添加ActiveAdmin将使用的帮助程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个供Formtastic使用的助手,但出现未定义的局部变量或方法错误。我不知道在哪里放置它才能起作用。

I'm creating a helper to be used by Formtastic but I get the undefined local variable or method error. I don't know where to put it so it can work.

我已经在application_helper.rb和app / helpers / active_admin / view_helpers.rb中尝试过

I already tried in the application_helper.rb and in app/helpers/active_admin/view_helpers.rb

推荐答案

您可以尝试在app / helpers /中定义它们,但需要通过活动管理员的初始化程序将它们包括在内,如下所示:

You can define them in app/helpers/ as you tried but you need to include them trough the active admin's initializer like this:

# in config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
    ....
end

module ActiveAdmin::ViewHelpers
  include ApplicationHelper
end

这篇关于Rails 3.如何添加ActiveAdmin将使用的帮助程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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