Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
要包含 Rails 助手,helper :helper_name 并包含所有助手,helper :all 在 application_controller 中指定。
现在,如何包含 N-1 个可用的助手?换句话说,如何排除极少数的助手?
我认为您需要编写一个自定义方法(例如,all_helpers)来获取所有助手的符号(:foo)或模块名称(FooHelper)(可能通过对app/helpers目录的文件系统调用),然后允许将排除列表传递给方法。然后将其称为:
all_helpers
:foo
FooHelper
app/helpers
helper all_helpers(:exclude => :bar)
查看 Rails 的ActionController::Helpers#all_application_helpers方法,了解如何从文件系统中提取帮助程序名称的详细信息。
ActionController::Helpers#all_application_helpers