Rails routing: Giving default values for path helpers

后端 未结 2 1259
梦如初夏
梦如初夏 2021-02-06 13:31

Is there some way to provide a default value to the url/path helpers?

I have an optional scope wrapping around all of my routes:

#config/routes.rb
Foo::A         


        
2条回答
  •  日久生厌
    2021-02-06 13:52

    In addition to CMW's answer, to get it to work with rspec, I added this hack in spec/support/default_url_options.rb

    ActionDispatch::Routing::RouteSet.class_eval do
      undef_method :default_url_options
      def default_url_options(options={})
        { :current_brand => default_brand }
      end
    end
    

提交回复
热议问题