开发者

Including and excluding helpers in Rails

开发者 https://www.devze.com 2022-12-11 15:04 出处:网络
To include a R开发者_如何学Goails helper, helper :helper_name and to include all helpers, helper :all is specified in the application_controller.

To include a R开发者_如何学Goails helper, helper :helper_name and to include all helpers, helper :all is specified in the application_controller.

Now, how to include say N-1 of the available helpers? In other words, how to exclude a very few helpers?


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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号