To include a Rails helper, helper :helper_name and to include all helpers, helper :all is specified in the application_controller.
要包含一个Rails helper, helper:helper_name并包含所有helper, helper:all在application_controller中指定。
Now, how to include say N-1 of the available helpers? In other words, how to exclude a very few helpers?
现在,如何包含N-1个可用的helper函数?换句话说,如何排除少数帮手?
1 个解决方案
#1
3
I think you would need to write a custom method (say, all_helpers
) to get symbols (:foo
) or module names (FooHelper
) for all of your helpers (probably via file system calls to the app/helpers
directory) and then allow an exclusion list to be passed to the method. Then call it something like:
我认为您需要编写一个自定义方法(比如all_helper)来为所有的helper(可能通过对app/helper目录的文件系统调用)获取符号(:foo)或模块名(FooHelper),然后允许将排除列表传递给方法。然后这样称呼它:
helper all_helpers(:exclude => :bar)
Take a look at Rails' ActionController::Helpers#all_application_helpers
method for details on how to pull helper names from the filesystem.
查看Rails的ActionController::: helper #all_application_helper方法,了解如何从文件系统中提取助手名的详细信息。
#1
3
I think you would need to write a custom method (say, all_helpers
) to get symbols (:foo
) or module names (FooHelper
) for all of your helpers (probably via file system calls to the app/helpers
directory) and then allow an exclusion list to be passed to the method. Then call it something like:
我认为您需要编写一个自定义方法(比如all_helper)来为所有的helper(可能通过对app/helper目录的文件系统调用)获取符号(:foo)或模块名(FooHelper),然后允许将排除列表传递给方法。然后这样称呼它:
helper all_helpers(:exclude => :bar)
Take a look at Rails' ActionController::Helpers#all_application_helpers
method for details on how to pull helper names from the filesystem.
查看Rails的ActionController::: helper #all_application_helper方法,了解如何从文件系统中提取助手名的详细信息。