如何在Ruby中的自定义方法中添加url_for

时间:2011-01-18 15:03:30

标签: ruby-on-rails forms module helper

我正在编写一个自定义表单助手,我需要在路由中声明的URL路径,但是我有这个错误:


    module CustomFormHelpers
      include ActionView::Helpers::TagHelper
      include ActionView::Helpers::FormTagHelper
      include ActionView::Helpers::FormOptionsHelper
      include ActionView::Helpers::CaptureHelper
      include ActionView::Helpers::AssetTagHelper
      include ActionView::Helpers::RawOutputHelper
      include ActionView::Helpers::JavaScriptHelper
      include ActionView::Helpers::UrlHelper

      def tags
        tags_path
      end

    end
in routes.rb

resources :tags

我需要在模块中包含哪些内容

1 个答案:

答案 0 :(得分:1)

重复using url_for in a lib folder module

简短回答:

include Rails.application.routes.url_helpers